[英]Why is “npm install” not failing when I've indicated a higher version of NodeJS?
我想在我的NodeJS項目中強制執行NodeJS和NPM的精確版本。 這是我的package.json:
{
"name": "nodesandbox",
"version": "0.0.1",
"dependencies": {
"less": "*"
},
"engines": {
"node": "0.10.25"
}
}
當我運行nvm ls
我得到了這個輸出:
v0.2.6
v0.7.12
v0.9.6
v0.10.12
v0.10.15
v0.10.21
current: v0.10.24
當我運行npm install
它工作正常,但我希望它失敗。 我已經按照這個鏈接的說明[1],這就是為什么我認為在引擎對象中設置節點版本應該工作但遺憾的是它不起作用。
[1] http://blog.nodejitsu.com/package-dependencies-done-right/#node-dependency-in-apps
看起來只有在從其他位置獲取包時才會檢查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"})
如果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"}
如果您仔細閱讀本手冊 ,可能會清楚原因(我實際上並非100%確定):
相比
npm install
(在包目錄中,沒有參數):在本地node_modules文件夾中安裝依賴項。
同
npm install <folder>
:安裝位於文件系統上的文件夾中的程序包。
第一個是安裝依賴項 ,第二個是安裝包 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.