3

I am currently using Ubuntu 18.04.4 and I am trying to install something using npm install but it always gives the error below. I tried other aliases as well (npm i, npm add) but the error persists.

npm install
npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path /home/dell/.npm/_cacache/content-v2/sha512/14/21/2143fe2b135cd8bfdad85c9c3f9ac46ab279a58dee631cfea1b9678167bd388d44f2d36739019c96ba3a4c4756b1ea6570f4dc8931fb8ad8230359521f80
npm ERR! errno -1
npm ERR! 
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR! 
npm ERR! To permanently fix this problem, please run:
npm ERR!   sudo chown -R 1001:1001 "/home/dell/.npm"

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/dell/.npm/_logs/2020-07-30T17_16_58_257Z-debug.log

When I run the sudo chown -R 1001:1001 "/home/dell/.npm" command, it does nothing, and the error remains when I run npm install again. I have also searched StackOverflow and other platforms for the answer, but no solution seems to solve this problem.

P.S: My node version is 12.18.3 and npm version is 6.14.6.

If someone can help me resolve this, I would really appreciate it!

  • I'm not 100% sure on this, but i know that 1001:1001 represent new owner (UID) and group (GID) numbers for the files. Try using the id command to find your own UID and GID and substitute those. Worst case scenario, I think, you have to do the chown again back to 1001:1001 to reset. – Nate G Jul 30 '20 at 17:46
  • Hi, I am new to Ubuntu, my UID and GID are 1001 and 1001. How do I reset? – Mehar Fatima Khan Jul 30 '20 at 17:47
  • I'm afraid that if 1001 is the correct UID and GID then I haven't hit on the solution. Sorry I can't be of further help. – Nate G Jul 31 '20 at 19:31
  • This is a known issue. Refer to this [answer on stackoverflow](https://stackoverflow.com/questions/58623072/npm-node-sass-installation-fails) and see it it works. – Mohsin Hayat Aug 03 '20 at 07:08
  • 3
    @MohsinHayat I can't figure out why you think that is the same issue – jcollum Sep 10 '21 at 15:51

1 Answers1

-2

I had problem with create-react-app. Solve it using yarn.

yarn global remove create-react-app

then

yarn global add create-react-app

and

create-react-app MyApp