On OSX 10.13.1, with n 2.1.7 and base node 9.2.0, when I run n [version], I get a list of cp errors for the entirety of the npm directory.
The new node version is implemented, though the npm version remains at 5.5.1.
cp: /usr/local/lib/node_modules/npm/doc/cli/npm.md: Permission denied
cp: /usr/local/lib/node_modules/npm/doc/cli/npm-config.md: Permission denied
cp: /usr/local/lib/node_modules/npm/doc/cli/npm-run-script.md: Permission denied
cp: /usr/local/lib/node_modules/npm/doc/cli/npm-init.md: Permission denied
cp: /usr/local/lib/node_modules/npm/doc/cli/npm-completion.md: Permission denied
cp: /usr/local/lib/node_modules/npm/doc/cli/npm-help.md: Permission denied
cp: /usr/local/lib/node_modules/npm/doc/cli/npm-logout.md: Permission denied
cp: /usr/local/lib/node_modules/npm/doc/cli/npm-token.md: Permission denied
cp: /usr/local/lib/node_modules/npm/doc/cli/npm-bundle.md: Permission denied
cp: /usr/local/lib/node_modules/npm/doc/cli/npm-prefix.md: Permission denied
cp: /usr/local/lib/node_modules/npm/doc/cli/npm-profile.md: Permission denied
cp: /usr/local/lib/node_modules/npm/doc/cli/npm-update.md: Permission denied
cp: /usr/local/lib/node_modules/npm/doc/cli/npm-root.md: Permission denied
cp: /usr/local/lib/node_modules/npm/doc/files/npm-shrinkwrap.json.md: Permission denied
cp: /usr/local/lib/node_modules/npm/doc/files/package.json.md: Permission denied
cp: /usr/local/lib/node_modules/npm/doc/files/npmrc.md: Permission denied
cp: /usr/local/lib/node_modules/npm/doc/files/npm-package-locks.md: Permission denied
cp: /usr/local/lib/node_modules/npm/doc/files/npm-folders.md: Permission denied
cp: /usr/local/lib/node_modules/npm/doc/files/package-lock.json.md: Permission denied
cp: /usr/local/lib/node_modules/npm/.mailmap: Permission denied
cp: /usr/local/lib/node_modules/npm/.travis.yml: Permission denied
Ideally, I always want the most recent version of npm that supports the version of node selected. That said, I mostly just want to stop the errors from appearing.
The default install location on OS X is to a system folder where a normal user does not have write permissions by default. You can strike the same sort of issue when using npm to install global modules. You have three main options:
1) put sudo in front of the command to run as super user
2) change the ownership of the relevant directories to yourself
3) tell n to use a custom location where you do have write permissions (see N_PREFIX)
I prefer option 2 myself.
Some relevant links:
https://docs.npmjs.com/getting-started/fixing-npm-permissions
https://pawelgrzybek.com/fix-priviliges-and-never-again-use-sudo-with-npm/
Interesting, @JohnRGee. I'd set NPM_PACKAGES in my .bash_profile (years ago now) to solve the same problem, but it looks like NPM_CONFIG_PREFIX is the new and more robust replacement. I agree though, chowning is the way to go!
Thanks!
Most helpful comment
The default install location on OS X is to a system folder where a normal user does not have write permissions by default. You can strike the same sort of issue when using npm to install global modules. You have three main options:
1) put
sudoin front of the command to run as super user2) change the ownership of the relevant directories to yourself
3) tell n to use a custom location where you do have write permissions (see
N_PREFIX)I prefer option 2 myself.
Some relevant links:
https://docs.npmjs.com/getting-started/fixing-npm-permissions
https://pawelgrzybek.com/fix-priviliges-and-never-again-use-sudo-with-npm/