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

Update README for cp... permission denied errors for /usr/local/lib/node_modules/npm #722

Closed
Hollyw00d opened this issue Apr 22, 2022 · 7 comments
Labels
docs Changes to README or other documentation

Comments

@Hollyw00d
Copy link

Problem

Permission errors in terminal on my Mac after installing the n npm package and running n lts.

Short Version

Can I submit a PR to merge into develop branch to updated README to explain permission problem fix that appear in terminal after installing the n npm package and running n lts?

Long Version

Issue was before in a closed issue:
#478

I experienced multiple Permission denied errors on my Mac (macOS Big Sur) like below in a number of folders like the example below after install the npm package and doing n lts in my terminal:

cp: /usr/local/include/node/openssl/ssl2.h: Permission denied

Can I submit a PR to merge into develop with instructions on how to Fix Permission Errors in a Mac? This will include running the code below in your terminal:

sudo chown -R $(whoami) /usr/local/lib/node_modules
sudo chown -R $(whoami) /usr/local/bin
sudo chown -R $(whoami) /usr/local/share
sudo chown -R $(whoami) /usr/local/include

Configuration Details

$ n --version
v8.2.0

$ node -v
v16.14.2

$ node -p process.platform
darwin
@shadowspawn
Copy link
Collaborator

The README does already touch on this, but does not mention permission errors. I see my explanation in #478 has had a some likes so maybe the README should be clearer about what why it is needed.

To avoid requiring sudo for n and npm global installs, it is suggested you either install to your home directory using N_PREFIX, or take ownership of the system directories:

# make cache folder (if missing) and take ownership
sudo mkdir -p /usr/local/n
sudo chown -R $(whoami) /usr/local/n
# make sure the required folders exist (safe to execute even if they already exist)
sudo mkdir -p /usr/local/bin /usr/local/lib /usr/local/include /usr/local/share
# take ownership of Node.js install destination folders
sudo chown -R $(whoami) /usr/local/bin /usr/local/lib /usr/local/include /usr/local/share

@shadowspawn shadowspawn added the docs Changes to README or other documentation label Apr 22, 2022
@Hollyw00d
Copy link
Author

@shadowspawn
Could also put /usr/local/lib/node_modules in the shell commands that are in the README? Like:

  • Replace sudo mkdir -p /usr/local/bin /usr/local/lib /usr/local/include /usr/local/share with below:
    sudo mkdir -p /usr/local/bin /usr/local/lib /usr/local/include /usr/local/share /usr/local/lib/node_modules
  • Replace sudo chown -R $(whoami) /usr/local/bin /usr/local/lib /usr/local/include /usr/local/share with below:
    sudo mkdir -p /usr/local/bin /usr/local/lib /usr/local/include /usr/local/share /usr/local/lib/node_modules /usr/local/lib/node_modules

Other than that the README looks great! Thanks for the quick change.

I'm going to try selling my teammates in my company to use the n npm package to switch Node versions rather than nvm or other solutions. It's so much easier. Thanks for your development on this!

@shadowspawn
Copy link
Collaborator

/usr/local/lib/node_modules is under /usr/local/lib so I think it is covered by the chown -R.

@Hollyw00d
Copy link
Author

Thanks @shadowspawn . You can close this issue. I'll let you know if it persists with other people.

@USMortality
Copy link

had this issue on a fresh macbook m2 setup, installed via homebrew. The four lines fixed it. Didn't see it in the readme, so maybe still worth adding... Thx!

@shadowspawn
Copy link
Collaborator

I opened a PR to expand the coverage in the README: #790

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Changes to README or other documentation
Projects
None yet
Development

No branches or pull requests

3 participants