Andreas Andreou
Andreas Andreou

Reputation: 848

Are there constraints on which npm version I can use based on my node version?

Is there any way to know if I can use a specific version of npm with a specific version of node?

I want to use latest npm (6.4.1 at the time of writing) with latest LTS (8.11.4 at time of writing).

I realise that the versions are pretty close that there might not be a problem but I have learned not to make assumptions about stuff I don't know :P

Upvotes: 1

Views: 217

Answers (1)

Harshal Yeole
Harshal Yeole

Reputation: 4993

I would suggest you install nvm (https://github.com/creationix/nvm/blob/master/README.md) and let it do the version management.

Usage: To download, compile, and install the latest release of node, do this:

nvm install node

And then in any new shell just use the installed version:

nvm use node

Or you can just run it:

nvm run node --version

Or, you can run any arbitrary command in a subshell with the desired version of node:

nvm exec 4.2 node --version

You can also get the path to the executable to where it was installed:

nvm which 5.0

Read more: Managing Node.js Versions with nvm

Upvotes: 2

Related Questions