npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

Trying to get React working

Ok, so I have been using npm with visual studio code for some time and have never really ran into any permission issues. The way I installed React was from the terminal globally with:

npm i -g create-react-app

I got this error when trying to create an app:

noah@noah-Inspiron-7559:~$ create-react-app web_tests

Creating a new React app in /home/noah/web_tests.

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

Unhandled rejection Error: EACCES: permission denied, open '/home/noah/.npm/_cacache/index-v5/2b/60/4cccecda7e38b19bb42facb7df03bac66b836196cdf1b302ee08869ff4b3'

npm ERR! cb() never called!

npm ERR! This is an error with npm itself. Please report this error at:
npm ERR!     <>

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/noah/.npm/_logs/2019-02-19T14_44_43_375Z-debug.log

Aborting installation.
  npm install --save --save-exact --loglevel error react react-dom react-scripts has failed.

Deleting generated file... package.json
Deleting web_tests / from /home/noah

Upon getting the above error I retry except with using the sudo command and I get a default React app started.
After exploring, I wanted to delete the src folder to do my own thing and was not able to. So, I go to the terminal and use sudo commands to delete the folder, because vs code isn’t supposed to be ran with sudo. Of course, this also means that I can’t create folders or files from within vs code either…

I am quite familiar with javascript, but was following a tutorial on setting up and getting started with React. Should I uninstall React and re-install it locally without using sudo? Or can anybody enlighten me on where I am going wrong in setting up a development environment for React?

There is an issue with installs using sudo leaving behind some files with root ownership. I do not think you need to reinstall react.

The quick fix is reset the ownerships in the folder mentioned in the error message:

sudo chown -R $(whoami) ~/.npm

The canonical bug and longer steps are: Global installs (sudo npm i -g) fail on Mac after 6.5 upgrade. Works fine after 6.4.1 downgrade.

Thank you! That worked wonderfully, I really need to get around to actually learning the how, what, and why behind the symbols used in commands.