Reputation: 5074
We are many persons who work on the same server where our projects live. Every one of course has his own virtual environment.
We all share the same node.js v4.4.5
and npm 2.15.5
.
However, I need npm >= 3.0.0
, so I installed a newer version /usr/local/n/versions/node/8.1.3/bin/npm
and I added aliases for node
and npm
into my ~/.bashrc
# ~/.bashrc
alias node='/usr/local/n/versions/node/8.1.3/bin/node'
alias npm='/usr/local/n/versions/node/8.1.3/bin/npm'
Then I sourced it source ~/.bashrc
and I thought it worked because
$ npm --version
5.0.3
Until I run npm run dev
$ npm run dev
> [email protected] dev /home/users/itsme/projects/training
> /usr/local/n/versions/node/8.1.3/bin/node build/dev-server.js
To use this template, you must update following to modules:
npm: 2.15.5 should be >= 3.0.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `/usr/local/n/versions/node/8.1.3/bin/node build/dev-server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/users/itsme/.npm/_logs/2017-07-06T15_13_11_912Z-debug.log
I don't understand why it seems to be running the shared outdated npm
instead of mine.
And here another quite weird thing
$ which npm # shows the shared one
$ `which npm` --version
2.15.5
Upvotes: 0
Views: 1215
Reputation: 5074
This has solved my problem (based on Oliver Charlesworth's answer)
export PATH="/usr/local/n/versions/node/8.1.3/bin:$PATH"
Upvotes: 0
Reputation: 533
https://github.com/creationix/nvm
Node version manager makes managing multiple node environments a simple task.
Upvotes: 1