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

Scripted installations of nvm cannot use sudo npx #5

Open
seevee opened this issue Jul 18, 2019 · 0 comments
Open

Scripted installations of nvm cannot use sudo npx #5

seevee opened this issue Jul 18, 2019 · 0 comments

Comments

@seevee
Copy link

seevee commented Jul 18, 2019

Issue

When attempting to run this script on Ubuntu 19.04, I got the following error:

sudo: npx: command not found

This despite having the following:

$ node -v
v12.6.0

$ npm -v
6.10.1

$ npx -v
6.10.1

Solution

I realized that I had installed nvm using their official script. This just adds the nvm shell function into the user's profile (~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc), which sudo won't have access to.

My solution for the problem, adopted from this StackOverflow post, was to symbolically link my nvm binaries into /usr/local/bin like so:

sudo ln -s "$NVM_DIR/versions/node/$(nvm version)/bin/node" "/usr/local/bin/node"
sudo ln -s "$NVM_DIR/versions/node/$(nvm version)/bin/npm" "/usr/local/bin/npm"
sudo ln -s "$NVM_DIR/versions/node/$(nvm version)/bin/npx" "/usr/local/bin/npx"

Goal

Given nvm's ubiquity and stance towards homebrew installations:

Homebrew installation is not supported. If you have issues with homebrew-installed nvm, please brew uninstall it, and install it using the instructions below, before filing an issue.

This issue might merit either inclusion into the script or a README mention.

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

1 participant