I am trying to lock node and npm version in my javascript project to ensure other developers have those specific versions when building bundles to commit. I just added this to my package.json:
"engineStrict" : true,
"engines": {
"node" : "10.10.0",
"npm" : "6.5.0"
},
Will this enforce those versions definitively? I am unfamiliar with locking down versions since I am used to be the sole developer on frontend projects or inheriting projects that have had this set up.
Alternatively, is there a benefit of also adding an .nvmrc
file that specifies the same version or is that redundant if I'm using engines?
I am trying to lock node and npm version in my javascript project to ensure other developers have those specific versions when building bundles to commit. I just added this to my package.json:
"engineStrict" : true,
"engines": {
"node" : "10.10.0",
"npm" : "6.5.0"
},
Will this enforce those versions definitively? I am unfamiliar with locking down versions since I am used to be the sole developer on frontend projects or inheriting projects that have had this set up.
Alternatively, is there a benefit of also adding an .nvmrc
file that specifies the same version or is that redundant if I'm using engines?
- 1 Does this answer your question? How can I specify the required Node.js version in package.json? – RobC Commented Apr 24, 2020 at 8:56
- Related: stackoverflow.com/q/60124530/320399 – blong Commented Feb 16, 2021 at 17:04
1 Answer
Reset to default 29Enforcing Node.js version
engineStrict
is deprecated since npm v3, but you can set engine-strict=true
in your .npmrc file. If you have engines
set in package.json, an error will be thrown when someone installs on an unsupported Node.js version.
.nvmrc for developer convenience
To make it easier for other developers to use a supported Node.js version, you can add a .nvmrc file. Now other developers can run nvm use
to automatically use a supported version.