timarney / react-app-rewired

Override create-react-app webpack configs without ejecting
MIT License
9.81k stars 425 forks source link

react-app-rewired: Permission denied #523

Closed sabine19 closed 2 years ago

sabine19 commented 3 years ago

Describe the bug React-App-Rewired runs into permission denied, when running in a docker container. This happens on start up, so you can't start the app with react-app-rewired. (Note: react-scripts only work fine)

To Reproduce

Steps to reproduce the behavior:

  1. take your react-app-rewired app and copy it to a docker container
  2. run npm install
  3. run npm start (or npx react-app-rewired start) depending on your setup (packages.json scripts section or gulpfile e.g.)
  4. See error
    
    node@7fdd14c9ecdf:/opt/project$ npm install

added 2471 packages, and audited 2472 packages in 36s

found 0 vulnerabilities node@7fdd14c9ecdf:/opt/project$ npm start

hegel-frontend@0.1.0 start react-app-rewired start

sh: 1: react-app-rewired: Permission denied npm ERR! code 126 npm ERR! path /opt/project npm ERR! command failed npm ERR! command sh -c react-app-rewired start

npm ERR! A complete log of this run can be found in: npm ERR! /home/node/.npm/_logs/2021-02-09T17_23_55_570Z-debug.log


Verbose Log output

node@7fdd14c9ecdf:/opt/project$ cat /home/node/.npm/_logs/2021-02-09T17_23_55_570Z-debug.log 0 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ] 1 info using npm@7.4.0 2 info using node@v15.6.0 3 timing config:load:defaults Completed in 1ms 4 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 1ms 5 timing config:load:builtin Completed in 1ms 6 timing config:load:cli Completed in 1ms 7 timing config:load:env Completed in 0ms 8 timing config:load:file:/opt/project/.npmrc Completed in 1ms 9 timing config:load:project Completed in 2ms 10 timing config:load:file:/home/node/.npmrc Completed in 0ms 11 timing config:load:user Completed in 0ms 12 timing config:load:file:/usr/local/etc/npmrc Completed in 0ms 13 timing config:load:global Completed in 0ms 14 timing config:load:cafile Completed in 0ms 15 timing config:load:validate Completed in 0ms 16 timing config:load:setUserAgent Completed in 1ms 17 timing config:load:setEnvs Completed in 0ms 18 timing config:load Completed in 6ms 19 verbose npm-session ee28113559a2a390 20 timing npm:load Completed in 12ms 21 timing command:run-script Completed in 8ms 22 timing command:start Completed in 10ms 23 verbose stack Error: command failed 23 verbose stack at ChildProcess. (/usr/local/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/index.js:64:27) 23 verbose stack at ChildProcess.emit (node:events:379:20) 23 verbose stack at maybeClose (node:internal/child_process:1065:16) 23 verbose stack at Process.ChildProcess._handle.onexit (node:internal/child_process:296:5) 24 verbose pkgid hegel-frontend@0.1.0 25 verbose cwd /opt/project 26 verbose Linux 4.15.0-88-generic 27 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "start" 28 verbose node v15.6.0 29 verbose npm v7.4.0 30 error code 126 31 error path /opt/project 32 error command failed 33 error command sh -c react-app-rewired start 34 verbose exit 126


**Expected behavior**
The app starts like on windows. 

**Desktop (please complete the following information):**
Server: Docker Engine - Community
 Engine:
  Version:          18.09.6
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.8
  Git commit:       481bc77
  Built:            Sat May  4 01:59:36 2019
  OS/Arch:          linux/amd64
  Experimental:     false
=> official docker hub image: https://hub.docker.com/layers/node/library/node/15.6.0/images/sha256-a65a1706f56a9ce393bb6059f49cb05bfab487226487be5da71f205eeb8c05ca

**Additional context**
Add any other context about the problem here.
We tried to change the permissions of the user, we tried to change the ownership of folder, 
nothing seems to work. 

snippet from package.json

"scripts": { "start": "react-app-rewired start", "build": "react-app-rewired build" }, "dependencies": { "@material-ui/core": "^4.11.2", "@material-ui/icons": "^4.11.2", "@material-ui/lab": "^4.0.0-alpha.57", "@monaco-editor/react": "^4.0.9", "@st/image-viewer": "^6.4.1492", "@st/react-ui-components": "^1.2.60", "@types/redux-thunk": "^2.1.0", "codemirror": "^5.59.1", "element-resize-detector": "^1.2.1", "intl-pluralrules": "^1.2.2", "material-design-icons-iconfont": "^6.1.0", "monaco-editor": "^0.22.3", "monaco-editor-webpack-plugin": "^3.0.0", "pepjs": "^0.5.3", "react": "^17.0.1", "react-codemirror2": "^7.2.1", "react-contextmenu": "^2.14.0", "react-dom": "^17.0.1", "react-intl": "^5.10.13", "react-json-inspector": "^7.1.1", "react-loader": "^2.4.7", "react-redux": "^7.2.2", "react-reflex": "^3.1.1", "react-resize-detector": "^5.2.0", "react-router-dom": "^5.2.0", "react-scripts": "4.0.1", "reactjs-popup": "^2.0.4", "redux-saga": "^1.1.3", "redux-thunk": "^2.3.0", "styled-components": "^5.2.1", "superagent": "^6.1.0", "toastr": "^2.1.4", "web-vitals": "^0.2.4" }, "devDependencies": { "@testing-library/jest-dom": "^5.11.8", "@testing-library/react": "^11.2.2", "@testing-library/user-event": "^12.6.0", "@types/element-resize-detector": "^1.1.2", "@types/jest": "^26.0.20", "@types/node": "^14.14.20", "@types/react": "^17.0.0", "@types/react-codemirror": "^1.0.3", "@types/react-dom": "^17.0.0", "@types/react-loader": "^2.4.4", "@types/react-redux": "^7.1.15", "@types/react-resize-detector": "^5.0.0", "@types/react-router-dom": "^5.1.7", "@types/superagent": "^4.1.10", "@types/toastr": "^2.1.38", "@types/uuid": "^8.3.0", "esm": "^3.2.25", "gulp": "^4.0.2", "npm-check": "^5.9.2", "react-app-rewired": "^2.1.8", "sass": "^1.32.2", "sass-loader": "^10.1.0", "teamcity-service-messages": "^0.1.11", "typescript": "^4.1.3" }



Any guidance in the right direction, would be appreciated! Thanks!
prashant-singhal-fudr commented 3 years ago

In your Dockerfile, use the syntax USER root on the top, or provide sufficient execute/read/write permissions to the docker-created user inside the container on the working directory using RUN chmod a+wrx .