create-react-app permissions issue with node_modules INSIDE the application

Viewed 54

I run:

npx create-react-app my-app

and get the following response.

Creating a new React app in /home/austin/executable-bash/test_dir/my-app.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...


added 1379 packages in 35s

186 packages are looking for funding
  run `npm fund` for details

Initialized a git repository.

Installing template dependencies using npm...
npm WARN deprecated source-map-resolve@0.6.0: See https://github.com/lydell/source-map-resolve#deprecated

added 39 packages in 4s

186 packages are looking for funding
  run `npm fund` for details
Removing template package using npm...

npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /home/austin/executable-bash/test_dir/my-app/node_modules/cra-template
npm ERR! dest /home/austin/executable-bash/test_dir/my-app/node_modules/.cra-template-AJu7jvgH
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/home/austin/executable-bash/test_dir/my-app/node_modules/cra-template' -> '/home/austin/executable-bash/test_dir/my-app/node_modules/.cra-template-AJu7jvgH'
npm ERR!  [Error: EACCES: permission denied, rename '/home/austin/executable-bash/test_dir/my-app/node_modules/cra-template' -> '/home/austin/executable-bash/test_dir/my-app/node_modules/.cra-template-AJu7jvgH'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'rename',
npm ERR!   path: '/home/austin/executable-bash/test_dir/my-app/node_modules/cra-template',
npm ERR!   dest: '/home/austin/executable-bash/test_dir/my-app/node_modules/.cra-template-AJu7jvgH'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/austin/.npm/_logs/2022-06-02T18_59_15_191Z-debug-0.log
`npm install --no-audit --save @testing-library/jest-dom@^5.14.1 @testing-library/react@^13.0.0 @testing-library/user-event@^13.2.1 web-vitals@^2.1.0` failed

The permissions issue seems to pertain to the node_modules INSIDE the application it just created. Weird right? I have a simple work around to change permissions inside the project:

 cd my-app

change permissions:

chown -R $USER node_modules

and install the packages:

npm i

This works but for obvious reasons it would be nice to have npx create-react-app actually work like it's supposed to. Any ideas?

0 Answers
Related