sindresorhus / guides

A collection of succinct guides - Public Domain
2.47k stars 458 forks source link

npm -g without sudo: different npm version? #24

Closed donaldpipowitch closed 9 years ago

donaldpipowitch commented 9 years ago

I followed your guide "Install npm packages globally without sudo on OS X and Linux" on Mac which works perfectly. If I install something like $ npm i -g babel I can now use the babel command. However I tried updating npm itself with $ npm i -g npm, but I still use the old sudo-ed version of npm, not the version inside .npm-packages. Is there a nice way to use the not-sudo-installed npm version and fallback to the sudo-installed npm version, if necessary?

kevva commented 9 years ago

https://github.com/npm/npm/wiki/Troubleshooting

donaldpipowitch commented 9 years ago

Sorry, but... help? None of the problems from your link seem to match my question?

kevva commented 9 years ago

Try changing the order in $PATH so that .npm-packages takes precedence over the other one.

donaldpipowitch commented 9 years ago

Ok, thanks.

kevva commented 9 years ago

@donaldpipowitch, did you find a solution?

donaldpipowitch commented 9 years ago

I don't know, I'm not that good at bash... You said "Try changing the order in $PATH so that .npm-packages takes precedence over the other one.", but isn't that what the guide already does at step 5: "PATH="$NPM_PACKAGES/bin:$PATH""? But using which npm returns /usr/local/bin/npm.

kevva commented 9 years ago

Try setting PATH=$PATH:$NPM_PACKAGES/bin.

donaldpipowitch commented 9 years ago

Strange. It looks like it is the same behavior. Nothing has changed.