Meteor npm install 从 package.json 安装了错误的版本

Meteor npm install installs wrong version from package.json

我的 package.json 在流星项目中有所有 angular 库版本 @2.0.0-rc.4 但后来我只是用 2.0.1 替换了它们 所以我的 package.json 看起来像这样:

{
  "name": "angular2-meteor-base",
  "private": true,
  "scripts": {
    "start": "meteor run",
    "test": "meteor test --driver-package practicalmeteor:mocha",
    "test:ci": "meteor test --once --driver-package dispatch:mocha-phantomjs"
  },
  "devDependencies": {
    "chai": "3.5.0",
    "chai-spies": "0.7.1"
  },
  "dependencies": {
    "@angular/common": "2.0.1",
    "@angular/compiler": "2.0.1",
    "@angular/core": "2.0.1",
    "@angular/forms": "0.2.0",
    "@angular/platform-browser": "2.0.1",
    "@angular/platform-browser-dynamic": "2.0.1",
    "@angular/router": "3.0.0-alpha.8",
    "angular2-meteor": "0.6.2",
    "angular2-meteor-auto-bootstrap": "0.6.0",
    "angular2-meteor-polyfills": "0.1.1",
    "angular2-meteor-tests-polyfills": "0.0.2",
    "es6-shim": "0.35.1",
    "meteor-node-stubs": "0.2.3",
    "reflect-metadata": "0.1.3",
    "rxjs": "5.0.0-beta.6",
    "zone.js": "0.6.12"
  }
}

删除 node_modules 后 运行 meteor npm installnpm install 控制台输出是这样的:

+-- @angular/common@2.0.0-rc.4
+-- @angular/compiler@2.0.0-rc.4
+-- @angular/core@2.0.0-rc.4
+-- @angular/forms@0.2.0
+-- @angular/platform-browser@2.0.0-rc.4
+-- @angular/platform-browser-dynamic@2.0.0-rc.4
+-- @angular/router@3.0.0-alpha.8
+-- angular2-meteor@0.6.2
+-- angular2-meteor-auto-bootstrap@0.6.0
+-- angular2-meteor-polyfills@0.1.1
+-- angular2-meteor-tests-polyfills@0.0.2
+-- bootstrap@4.0.0-alpha.2
+-- chai@3.5.0
| +-- assertion-error@1.0.2
| +-- deep-eql@0.1.3
| | `-- type-detect@0.1.1
| `-- type-detect@1.0.0
+-- chai-spies@0.7.1
+-- es6-shim@0.35.1
+-- meteor-node-stubs@0.2.3
| +-- assert@1.3.0
| +-- browserify-zlib@0.1.4
| | `-- pako@0.2.8
| +-- buffer@4.5.1
| | +-- base64-js@1.1.2
| | +-- ieee754@1.1.6
| | `-- isarray@1.0.0
| +-- console-browserify@1.1.0
| | `-- date-now@0.1.4
| +-- constants-browserify@1.0.0
| +-- crypto-browserify@3.11.0
| | +-- browserify-cipher@1.0.0
| | | +-- browserify-aes@1.0.6
| | | | +-- buffer-xor@1.0.3
| | | | `-- cipher-base@1.0.2
| | | +-- browserify-des@1.0.0
| | | | +-- cipher-base@1.0.2
| | | | `-- des.js@1.0.0
| | | |   `-- minimalistic-assert@1.0.0
| | | `-- evp_bytestokey@1.0.0
| | +-- browserify-sign@4.0.0
| | | +-- bn.js@4.11.1
| | | +-- browserify-rsa@4.0.1
| | | +-- elliptic@6.2.3
| | | | +-- brorand@1.0.5
| | | | `-- hash.js@1.0.3
| | | `-- parse-asn1@5.0.0
| | |   +-- asn1.js@4.5.2
| | |   | `-- minimalistic-assert@1.0.0
| | |   +-- browserify-aes@1.0.6
| | |   | +-- buffer-xor@1.0.3
| | |   | `-- cipher-base@1.0.2
| | |   `-- evp_bytestokey@1.0.0
| | +-- create-ecdh@4.0.0
| | | +-- bn.js@4.11.1
| | | `-- elliptic@6.2.3
| | |   +-- brorand@1.0.5
| | |   `-- hash.js@1.0.3
| | +-- create-hash@1.1.2
| | | +-- cipher-base@1.0.2
| | | +-- ripemd160@1.0.1
| | | `-- sha.js@2.4.5
| | +-- create-hmac@1.1.4
| | +-- diffie-hellman@5.0.2
| | | +-- bn.js@4.11.1
| | | `-- miller-rabin@4.0.0
| | |   `-- brorand@1.0.5
| | +-- inherits@2.0.1
| | +-- pbkdf2@3.0.4
| | +-- public-encrypt@4.0.0
| | | +-- bn.js@4.11.1
| | | +-- browserify-rsa@4.0.1
| | | `-- parse-asn1@5.0.0
| | |   +-- asn1.js@4.5.2
| | |   | `-- minimalistic-assert@1.0.0
| | |   +-- browserify-aes@1.0.6
| | |   | +-- buffer-xor@1.0.3
| | |   | `-- cipher-base@1.0.2
| | |   `-- evp_bytestokey@1.0.0
| | `-- randombytes@2.0.3
| +-- domain-browser@1.1.7
| +-- events@1.1.0
| +-- http-browserify@1.7.0
| | +-- Base64@0.2.1
| | `-- inherits@2.0.1
| +-- https-browserify@0.0.1
| +-- os-browserify@0.2.1
| +-- path-browserify@0.0.0
| +-- process@0.11.2
| +-- punycode@1.4.1
| +-- querystring-es3@0.2.1
| +-- readable-stream@2.0.6
| | +-- core-util-is@1.0.2
| | +-- inherits@2.0.1
| | +-- isarray@1.0.0
| | +-- process-nextick-args@1.0.6
| | `-- util-deprecate@1.0.2
| +-- stream-browserify@2.0.1
| | `-- inherits@2.0.1
| +-- string_decoder@0.10.31
| +-- timers-browserify@1.4.2
| +-- tty-browserify@0.0.0
| +-- url@0.11.0
| | +-- punycode@1.3.2
| | `-- querystring@0.2.0
| +-- util@0.10.3
| | `-- inherits@2.0.1
| `-- vm-browserify@0.0.4
|   `-- indexof@0.0.1
+-- reflect-metadata@0.1.3
+-- rxjs@5.0.0-beta.6
+-- tether@1.3.7
`-- zone.js@0.6.12

那么为什么会发生这种情况,我应该如何安装正确版本的库?

在新目录中尝试相同的 package.json 文件,看看是否有相同的结果。

我在一个空目录中使用了你的 package.json 和 运行 npm i,结果如下:

angular2-meteor-base@ /Volumes/HD2/Downloads/tmp
├── @angular/common@2.0.1 
├── @angular/compiler@2.0.1 
├── @angular/core@2.0.1 
├── @angular/forms@0.2.0 
├── @angular/platform-browser@2.0.1 
├── @angular/platform-browser-dynamic@2.0.1 
├── @angular/router@3.0.0-alpha.8 
├── angular2-meteor@0.6.2 
├── angular2-meteor-auto-bootstrap@0.6.0 
├── angular2-meteor-polyfills@0.1.1 
├── angular2-meteor-tests-polyfills@0.0.2 
├─┬ chai@3.5.0 
│ ├── assertion-error@1.0.2 
│ ├─┬ deep-eql@0.1.3 
│ │ └── type-detect@0.1.1 
│ └── type-detect@1.0.0 
├── chai-spies@0.7.1 
├── es6-shim@0.35.1 
├─┬ meteor-node-stubs@0.2.3 
│ ├── assert@1.3.0 
│ ├─┬ browserify-zlib@0.1.4 
│ │ └── pako@0.2.8 
│ ├─┬ buffer@4.5.1 
│ │ ├── base64-js@1.1.2 
│ │ ├── ieee754@1.1.6 
│ │ └── isarray@1.0.0 
│ ├─┬ console-browserify@1.1.0 
│ │ └── date-now@0.1.4 
│ ├── constants-browserify@1.0.0 
│ ├─┬ crypto-browserify@3.11.0 
│ │ ├─┬ browserify-cipher@1.0.0 
│ │ │ ├─┬ browserify-aes@1.0.6 
│ │ │ │ ├── buffer-xor@1.0.3 
│ │ │ │ └── cipher-base@1.0.2 
│ │ │ ├─┬ browserify-des@1.0.0 
│ │ │ │ ├── cipher-base@1.0.2 
│ │ │ │ └─┬ des.js@1.0.0 
│ │ │ │   └── minimalistic-assert@1.0.0 
│ │ │ └── evp_bytestokey@1.0.0 
│ │ ├─┬ browserify-sign@4.0.0 
│ │ │ ├── bn.js@4.11.1 
│ │ │ ├── browserify-rsa@4.0.1 
│ │ │ ├─┬ elliptic@6.2.3 
│ │ │ │ ├── brorand@1.0.5 
│ │ │ │ └── hash.js@1.0.3 
│ │ │ └─┬ parse-asn1@5.0.0 
│ │ │   ├─┬ asn1.js@4.5.2 
│ │ │   │ └── minimalistic-assert@1.0.0 
│ │ │   ├─┬ browserify-aes@1.0.6 
│ │ │   │ ├── buffer-xor@1.0.3 
│ │ │   │ └── cipher-base@1.0.2 
│ │ │   └── evp_bytestokey@1.0.0 
│ │ ├─┬ create-ecdh@4.0.0 
│ │ │ ├── bn.js@4.11.1 
│ │ │ └─┬ elliptic@6.2.3 
│ │ │   ├── brorand@1.0.5 
│ │ │   └── hash.js@1.0.3 
│ │ ├─┬ create-hash@1.1.2 
│ │ │ ├── cipher-base@1.0.2 
│ │ │ ├── ripemd160@1.0.1 
│ │ │ └── sha.js@2.4.5 
│ │ ├── create-hmac@1.1.4 
│ │ ├─┬ diffie-hellman@5.0.2 
│ │ │ ├── bn.js@4.11.1 
│ │ │ └─┬ miller-rabin@4.0.0 
│ │ │   └── brorand@1.0.5 
│ │ ├── inherits@2.0.1 
│ │ ├── pbkdf2@3.0.4 
│ │ ├─┬ public-encrypt@4.0.0 
│ │ │ ├── bn.js@4.11.1 
│ │ │ ├── browserify-rsa@4.0.1 
│ │ │ └─┬ parse-asn1@5.0.0 
│ │ │   ├─┬ asn1.js@4.5.2 
│ │ │   │ └── minimalistic-assert@1.0.0 
│ │ │   ├─┬ browserify-aes@1.0.6 
│ │ │   │ ├── buffer-xor@1.0.3 
│ │ │   │ └── cipher-base@1.0.2 
│ │ │   └── evp_bytestokey@1.0.0 
│ │ └── randombytes@2.0.3 
│ ├── domain-browser@1.1.7 
│ ├── events@1.1.0 
│ ├─┬ http-browserify@1.7.0 
│ │ ├── Base64@0.2.1 
│ │ └── inherits@2.0.1 
│ ├── https-browserify@0.0.1 
│ ├── os-browserify@0.2.1 
│ ├── path-browserify@0.0.0 
│ ├── process@0.11.2 
│ ├── punycode@1.4.1 
│ ├── querystring-es3@0.2.1 
│ ├─┬ readable-stream@2.0.6 
│ │ ├── core-util-is@1.0.2 
│ │ ├── inherits@2.0.1 
│ │ ├── isarray@1.0.0 
│ │ ├── process-nextick-args@1.0.6 
│ │ └── util-deprecate@1.0.2 
│ ├─┬ stream-browserify@2.0.1 
│ │ └── inherits@2.0.1 
│ ├── string_decoder@0.10.31 
│ ├── timers-browserify@1.4.2 
│ ├── tty-browserify@0.0.0 
│ ├─┬ url@0.11.0 
│ │ ├── punycode@1.3.2 
│ │ └── querystring@0.2.0 
│ ├─┬ util@0.10.3 
│ │ └── inherits@2.0.1 
│ └─┬ vm-browserify@0.0.4 
│   └── indexof@0.0.1 
├── reflect-metadata@0.1.3 
├── UNMET PEER DEPENDENCY rxjs@5.0.0-beta.6
└── UNMET PEER DEPENDENCY zone.js@0.6.12

npm WARN @angular/core@2.0.1 requires a peer of rxjs@5.0.0-beta.12 but none was installed.
npm WARN @angular/core@2.0.1 requires a peer of zone.js@^0.6.21 but none was installed.

我发现依赖项实际上是从 npm-shrinkwrap.json 解析的,它具有控制台输出中的依赖项版本。