What to me seems like the best option is the one suggested in the npm documentation, which is to first check where global node_modules are installed by default by running npm config get prefix. (optional) Test: Download a package globally without using sudo. Open or create a ~/.profile or ~/.bash_profile file and add this line:īack on the command line, update your system variables, or restart the terminal: Make a directory for global installations:Ĭonfigure npm to use the new directory path: Npm cache verify # or, npm cache clean for npm version below 5.x.x (optional) In case you have a erroneous installation, first uninstall it: npm uninstall # use sudo if you used it while installation Solution/ Suggestion: Change npm's Default Directory (from official docs)īack-up your computer before moving forward. The instant way out is to run the npm install using sudo, but this may give you the same error, or improper installation.ĪND changing directory ownership is not a good option, a temporary patch. ISSUE: You (the user) don't have the right set of permissions for the directory. With either of those approaches, you will be able to do the following without using sudo Npm ERR! ' > ~/.bashrc #or ~/.profile or ~/.bash_profile or ~/.zshenv depending on the current Operative System npm ERR! Error: EACCES, open '/Users/chietala/.npm/-/all/.cache.json' I have a feeling this is a permissions issue? I am already the admin. Getting weird permission errors when you're trying to npm install. I just installed node and npm through the package on, and whenever I try to search or install something with npm, it throws the following error unless I sudo the command. Please don't give random JavaScript code root access to your machine.
0 Comments
Leave a Reply. |