[英]Why is “npm install” not failing when I've indicated a higher version of NodeJS?
I would like to enforce exact versions of NodeJS and NPM in my NodeJS project. 我想在我的NodeJS项目中强制执行NodeJS和NPM的精确版本。 This is my package.json: 这是我的package.json:
{
"name": "nodesandbox",
"version": "0.0.1",
"dependencies": {
"less": "*"
},
"engines": {
"node": "0.10.25"
}
}
When I run nvm ls
I get this output: 当我运行nvm ls
我得到了这个输出:
v0.2.6
v0.7.12
v0.9.6
v0.10.12
v0.10.15
v0.10.21
current: v0.10.24
When I run npm install
it works fine, but I would like it to fail. 当我运行npm install
它工作正常,但我希望它失败。 I have followed instructions from this link [1], which is why I think setting the node version in the engines object should work but sadly it is not working. 我已经按照这个链接的说明[1],这就是为什么我认为在引擎对象中设置节点版本应该工作但遗憾的是它不起作用。
[1] http://blog.nodejitsu.com/package-dependencies-done-right/#node-dependency-in-apps [1] http://blog.nodejitsu.com/package-dependencies-done-right/#node-dependency-in-apps
It looks like the engine
dependencies are only checked when the package is taken from another location: 看起来只有在从其他位置获取包时才会检查engine
依赖关系:
[timwolla@/tmp/test2]npm install ../test
npm WARN engine nodesandbox@0.0.1: wanted: {"node":"0.10.30"} (current: {"node":"v0.10.26","npm":"1.4.3"})
If engineStrict
is set to true: 如果engineStrict
设置为true:
[timwolla@/tmp/test2]npm install ../test
npm ERR! notsup Unsupported
npm ERR! notsup Not compatible with your version of node/npm: nodesandbox@0.0.1
npm ERR! notsup Required: {"node":"0.10.30"}
npm ERR! notsup Actual: {"npm":"1.4.3","node":"v0.10.26"}
If you read the manual carefully it may become clear why (I'm not 100% sure about this actually): 如果您仔细阅读本手册 ,可能会清楚原因(我实际上并非100%确定):
Compare 相比
npm install
(in package directory, no arguments):npm install
(在包目录中,没有参数):Install the dependencies in the local node_modules folder. 在本地node_modules文件夹中安装依赖项。
with 同
npm install <folder>
:npm install <folder>
:Install a package that is sitting in a folder on the filesystem. 安装位于文件系统上的文件夹中的程序包。
The first states to install the dependencies , while the second installs the package . 第一个是安装依赖项 ,第二个是安装包 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.