Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cp... permission denied errors for /usr/local/lib/node_modules/npm #478

Closed
mikestopcontinues opened this issue Nov 22, 2017 · 3 comments
Closed

Comments

@mikestopcontinues
Copy link

Describe issue...

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

Steps to reproduce issue...

  1. n latest

Describe the results you expected

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.

@shadowspawn
Copy link
Collaborator

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/

@mikestopcontinues
Copy link
Author

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!

@shadowspawn
Copy link
Collaborator

I opened a PR to expand the permission coverage in the README based on the above comment: #790

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants