Gre*_*fan 9 npm docker reactjs
我在尝试在 React 应用程序中构建 docker 容器时遇到权限错误。
\n我尝试利用社区答案,但没有帮助。
\n以下相关讨论我尝试过:
id -un
sudo chown -R myUser:myUser /usr/local/lib/node_modules
sudo chown -R ownerName: /usr/local/lib/node_modules
sudo chown -R $USER /usr/local/lib/node_modules
sudo chown -R $USER /app/node_modules
sudo npm install -g --unsafe-perm=true --allow-root
sudo
:sudo npm install
将其添加到docker-compose
文件中也没有帮助:
environment:\n - CHOKIDAR_USEPOLLING=true\n
Run Code Online (Sandbox Code Playgroud)\n我正在尝试使用以下命令进行构建:docker-compose up --build
Dockerfile.dev 文件
\nFROM node:alpine\n\nWORKDIR \'/app\'\n\nCOPY package.json .\nRUN npm install\n\nCOPY . .\n\nCMD ["npm", "run", "start"]\n
Run Code Online (Sandbox Code Playgroud)\ndocker-compose.yml 文件
\nversion: "3"\nservices:\n web:\n stdin_open: true\n environment:\n - CHOKIDAR_USEPOLLING=true\n build:\n context: .\n dockerfile: Dockerfile.dev\n ports:\n - "4000:4000"\n volumes:\n - /app/node_modules\n - .:/app\n
Run Code Online (Sandbox Code Playgroud)\n错误
\nBuilding web\nStep 1/6 : FROM node:alpine\n ---> 50389f7769d0\nStep 2/6 : WORKDIR \'/app\'\n ---> Using cache\n ---> bb4d4ffdeb02\nStep 3/6 : COPY package.json .\n ---> Using cache\n ---> c4e5fce6b1e0\nStep 4/6 : RUN npm install\n ---> Using cache\n ---> 9383aea4aba6\nStep 5/6 : COPY . .\n ---> Using cache\n ---> 98ea3037694f\nStep 6/6 : CMD ["npm", "run", "start"]\n ---> Using cache\n ---> 6edf3365a6db\nSuccessfully built 6edf3365a6db\nSuccessfully tagged app_web:latest\nStarting app_web_1 ... \nStarting app_web_1 ... done\nAttaching to app_web_1\nweb_1 | \nweb_1 | > app@0.1.0 start\nweb_1 | > react-scripts start\nweb_1 | \nweb_1 | \xe2\x84\xb9 \xef\xbd\xa2wds\xef\xbd\xa3: Project is running at http://172.20.0.2/\nweb_1 | \xe2\x84\xb9 \xef\xbd\xa2wds\xef\xbd\xa3: webpack output is served from \nweb_1 | \xe2\x84\xb9 \xef\xbd\xa2wds\xef\xbd\xa3: Content not from webpack is served from /app/public\nweb_1 | \xe2\x84\xb9 \xef\xbd\xa2wds\xef\xbd\xa3: 404s will fallback to /\nweb_1 | Starting the development server...\nweb_1 | \nweb_1 | Failed to compile.\nweb_1 | \nweb_1 | EACCES: permission denied, mkdir \'/app/node_modules/.cache\'\n
Run Code Online (Sandbox Code Playgroud)\n任何帮助将不胜感激
\n小智 13
试试这个 Docker - EACCES:权限被拒绝,mkdir '/app/node_modules/.cache'
这对我有用
RUN chown -R node:node /app/node_modules
Run Code Online (Sandbox Code Playgroud)
或 sh 进入 docker 容器并运行
chown -R node:node /app/node_modules
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
16411 次 |
最近记录: |