JS:nvmrc 与 package.json 引擎? [英] JS: nvmrc vs package.json engines?

查看:48
本文介绍了JS:nvmrc 与 package.json 引擎?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的 javascript 项目中锁定 node 和 npm 版本,以确保其他开发人员在构建要提交的包时拥有这些特定版本.我刚刚将此添加到我的 package.json 中:

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"
  },

这会最终强制执行这些版本吗?我不熟悉锁定版本,因为我曾经是前端项目的唯一开发人员或继承了此设置的项目.
或者,添加一个指定相同版本的 .nvmrc 文件是否有好处,或者如果我使用引擎是多余的?

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?

推荐答案

Enforcing Node.js version

engineStrict 自 npm v3 起已弃用,但您可以在 .npmrc 文件中设置 engine-strict=true.如果您在 package.json 中设置了 engines,当有人安装在不受支持的 Node.js 版本上时会抛出错误.

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.

为了让其他开发者更容易使用受支持的 Node.js 版本,您可以添加一个 .nvmrc 文件.现在其他开发者可以运行 nvm use 来自动使用支持的版本.

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.

这篇关于JS:nvmrc 与 package.json 引擎?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆