-
-
Notifications
You must be signed in to change notification settings - Fork 750
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
Switching node version changes installed npm #210
Comments
npm is bundled with node. It will switch to whichever npm version was bundled with the node version you switch to. |
Actually the issue as I see it is that it seems impossible to keep npm updated properly - the npm version is "locked" to the node version it was installed with! For example if I install There must be some way to update npm and have it stick, right? Otherwise I can't use this amazingly handy utility. :( |
node and npm seem to be going their separate ways. Here's how to decouple completely. # save a list of what is installed globally
npm -g ls --depth=0 > npm_global_packages.txt
# Make a directory for global installations:
mkdir ~/.npm-global
# Configure npm to use the new directory path:
npm config set prefix '~/.npm-global'
# NOTE: add this to your profile as well:
export PATH=~/.npm-global/bin:$PATH
npm install npm -g
echo "NPM global directory changed: $(npm config get prefix)"
# Remove old npm
sudo rm /usr/local/bin/npm
sudo rm -rf /usr/local/lib/node_modules
# Now reinstall any global npm modules using the list we created above |
Perhaps with the changes suggested in #212. Now would also be a good time to introduce a similar command such as |
Yep it would be great to be able to switch npm separately. Most of the time having to do |
I think all we have to do is to tell n to only copy |
What about npmbrew? |
Oh yeah, at a first glance npmbrew does look pretty good. |
I'm not convinced that using newer npm with older node will cause you any fewer problems than using older npm with newer node. The safest way to go is going to be to use the npm bundled with your node version, especially since whoever else is to |
I found it more annoying that "npm list -g" throws a lot of errors (invalid/extraneouse mostly) after I changed node-version thru n ... But why I have to do that? Funny fact: As root "npm -v" always returns the version of the RPM i installed to install node/n ... for every other user "npm -v" works as expected ... |
+1, because npm3 breaks some of my project, so I need to downgrade to npm2 every time I switch. |
@bucaran thanks for suggestion! I'll give |
Related #364 |
This issue has not had any activity in over six months. It isn't likely to get acted on due to this report. Feel free to open a new issue if it comes up again, with new information and renewed interest. Thank you for your contributions. |
For future visitors to this page, please note that there is now support for preserving the |
Not sure why, but whenever I change the node version using
n
, my globalnpm
is reverted to an old version and I have to runnpm install npm@latest -g
every time I switch. Is there a way I can telln
to ignore whatever internalnpm
it is using?The text was updated successfully, but these errors were encountered: