如何指定/强制在 package.json 中使用特定的 node.js 版本? [英] How to specify/enforce a specific node.js version to use in package.json?

查看:144
本文介绍了如何指定/强制在 package.json 中使用特定的 node.js 版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果用户使用项目中定义的不同 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屋!

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