2

I am trying to npm install my in react project and am getting this error: enter image description here

I've tried sudo chown -R whoami to working directory and still no luck.. what else can i do?

julz oh
  • 285
  • 6
  • 17

1 Answers1

1

This is a common problem when you install packages using sudo. That's why you shouldn't install any package using sudo keyword.

The solution: Delete node_modules folder. If it says that you don't have permission than delete it directly from folder (not from IDE) or through terminal.

After that install your packages again. This time only npm i without sudo.

Getsumi3
  • 211
  • 2
  • 10
  • 1
    Regarding "*you shouldn't install any package using sudo keyword*": For the general case, I disagree, because of the case of globally-installed packages. e.g. the [official `npm` documentation](https://docs.npmjs.com/try-the-latest-stable-version-of-npm#upgrading-on-nix-osx-linux-etc) says: "*`npm install -g npm@latest` ... you may need to prefix these commands with sudo, especially on Linux, or OS X if you installed Node using its default installer.*" – Abdull Dec 16 '22 at 14:59