22

I am using .nvmrc file to lock in my Node version for my project. Is there a way to lock in my NPM version as well? I want to make sure that anyone that runs my project is on the same setup.

jjoan
  • 383
  • 1
  • 3
  • 17

2 Answers2

11

Yes. You can use the engines property in your package.json to specify an exact NPM version (or version range) for running your project.

pjivers
  • 1,769
  • 18
  • 27
-1

No - nvm does not support locking the npm version (it is an open feature request).


Each version of node installs with a specific version of npm. The easiest way to make sure developers uses the same npm version would be to use the npm version that comes installed with the node version you specify in the project's .nvrmc.

In some cases, your project may be required to use a newer npm version while being locked to an older node version. Ideally you would update the node version along with npm, otherwise you'll need to document this somewhere in your project (e.g. package.json, CONTRIBUTING.md, README.md, etc.).

JBallin
  • 8,481
  • 4
  • 46
  • 51