最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Node.js Error: EACCES: permission denied, mkdir in Windows - Stack Overflow

programmeradmin2浏览0评论

There is a Node.js code running well in the alpine node Docker container in Linux (and macOS) environments.

import fs from 'fs';
...
const processorDir = path.join(LOCAL_PROC_PATH, 'processor');
if (!fs.existsSync(processorDir)) {
    fs.mkdirSync(processorDir);
}

In Windows in same alpine node Docker container it fails with:

Error: EACCES: permission denied, mkdir '/mnt/app/processor'

Replacing with the following did not help

import fs from 'fs-extra';
...
fs.ensureDirSync(processorDir);

In Dockerfile, we have

RUN mkdir -p /mnt/app/
RUN chown -R node:node /mnt/app/
USER node

/mnt/app/ above is the LOCAL_PROC_PATH. So the node user can create dirs for processing. And it does in Linux environment.

The attempt to create and use another Linux user and assign the admin privilege led to the same error.

发布评论

评论列表(0)

  1. 暂无评论