如何指定/强制在 package.json 中使用特定的 node.js 版本? [英] How to specify/enforce a specific node.js version to use in package.json?
问题描述
如果用户使用项目中定义的不同 node.js 版本,我正在寻找一种中断构建的方法.
I am searching for a way to break the build, if a user is using a different node.js version as defined in the project.
最好在 grunt 或 bower 或 npm 中进行一些检查以停止,如果某个 npm/node 版本未用于运行当前构建.
Ideally to put some checks in grunt or bower or npm to stop, if a certain npm/node version is not used to run the current build.
推荐答案
您可以在 package.json 中使用engineStrict"属性
You can use the "engineStrict" property in your package.json
查看文档了解更多信息:https://docs.npmjs.com/files/package.json
Check the docs for more information: https://docs.npmjs.com/files/package.json
2019 年 6 月 23 日更新
"engineStrict"
属性在 npm 3.0.0 中被删除.
"engineStrict"
property is removed in npm 3.0.0.
参考:https://docs.npmjs.com/files/package.json#enginestrict
这篇关于如何指定/强制在 package.json 中使用特定的 node.js 版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!