最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - JS: nvmrc vs package.json engines? - Stack Overflow

programmeradmin0浏览0评论

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?

Share Improve this question edited Apr 24, 2020 at 9:52 burtonLowel asked Apr 24, 2020 at 8:03 burtonLowelburtonLowel 7941 gold badge9 silver badges23 bronze badges 2
  • 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
Add a comment  | 

1 Answer 1

Reset to default 29

Enforcing 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.

发布评论

评论列表(0)

  1. 暂无评论