如果我执行npm install mongodb
,则会安装所需版本的mongodb
而不会出现问题:
- bson@0.1.5 node_modules/mongodb/node_modules/bson
mongo-invoices@0.0.0 /home/lorencm/Downloads/mongo-invoices
└─┬ mongodb@2.1.6
├── es6-promise@3.0.2
├─┬ mongodb-core@1.3.1
│ ├── bson@0.4.21
│ └─┬ require_optional@1.0.0
│ ├── resolve-from@2.0.0
│ └── semver@5.1.0
└─┬ readable-stream@1.0.31
├── core-util-is@1.0.2
├── inherits@2.0.1
├── isarray@0.0.1
└── string_decoder@0.10.31
只要存储了package.json
中的所有依赖项(见下文)并使用npm install
,我就会失败(见下文)来安装mongodb@2.1.6
,而是安装mongodb@1.1.11
}:
{
"name": "mongo-invoices",
"version": "0.0.0",
"description": "open-source invoice system build on node.js and mongodb",
"main": "app.js",
"dependencies": {
"accounting": "~0.4.1",
"bcrypt-nodejs": "0.0.3",
"emailjs": "~1.0.2",
"express": "~4.13.4",
"i18n": "^0.6.0",
"jade": "~1.11.0",
"moment": "~2.11.2",
"mongodb": "~2.1.6",
"stylus": "~0.53.0"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git://github.com/gianlucadelgobbo/mongo-invoices.git"
},
"keywords": [
"invoices",
"mongodb",
"node.js"
],
"author": "Gianluca Del Gobbo <g.delgobbo@flyer.it>",
"license": "BSD",
"readmeFilename": "README.md",
"private": true
}
make[1]: *** [Release/obj.target/bson/ext/bson.o] Error 1
make[1]: Leaving directory `/home/lorencm/Downloads/mongo-invoices/node_modules/mongodb/node_modules/bson/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:270:23)
gyp ERR! stack at emitTwo (events.js:100:13)
gyp ERR! stack at ChildProcess.emit (events.js:185:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 4.2.0-23-generic
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
gyp ERR! cwd /home/lorencm/Downloads/mongo-invoices/node_modules/mongodb/node_modules/bson
gyp ERR! node -v v5.5.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
make: *** [node_gyp] Error 1
child process exited with code 2
- bson@0.4.21 node_modules/bson
- core-util-is@1.0.2 node_modules/core-util-is
- es6-promise@3.0.2 node_modules/es6-promise
- inherits@2.0.1 node_modules/inherits
- isarray@0.0.1 node_modules/isarray
- resolve-from@2.0.0 node_modules/resolve-from
- semver@5.1.0 node_modules/semver
- require_optional@1.0.0 node_modules/require_optional
- mongodb-core@1.3.1 node_modules/mongodb-core
- string_decoder@0.10.31 node_modules/string_decoder
- readable-stream@1.0.31 node_modules/readable-stream
mongo-invoices@0.0.0 /home/lorencm/Downloads/mongo-invoices
└─┬ mongodb@1.1.11
└── bson@0.1.5
为什么不安装我在package.json
中指定的版本?
答案 0 :(得分:1)
由于npm-shrinkwrap.json文件包含以下内容,应用程序无法安装var loader = new THREE.ObjectLoader();
loader.load("zebra.json",function ( obj ) {
scene.add( obj );
});
版本:
此命令会锁定程序包依赖项的版本,以便您可以精确控制安装程序包时将使用的每个依赖项的版本。
如果您检查2.1.6
的{{3}},则会发现mongo-invoices
的指定版本为mongodb