问题描述:

Using:

node v4.6.2, npm 2.15.5, nvm 0.29.0, Homebrew 1.1.1-64-g17bad9a, macOS 10.12.1

Steps:

  • I update package.json,
  • delete all my modules: rm -fr node_modules,
  • reinstall everything: nvm exec npm install,
  • and update the shrinkwrap: nvm exec npm shrinkwrap --dev.

Result:

Every time, the from field of every module will change between a name and a URL, as pictured in this partial capture of npm-shrinkwrap.json diff:

diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json

index e1f679a..476febe 100644

--- a/npm-shrinkwrap.json

+++ b/npm-shrinkwrap.json

@@ -4,86 +4,86 @@

"dependencies": {

"active-model-adapter": {

"version": "2.1.1",

- "from": "active-mo[email protected]",

+ "from": "https://registry.npmjs.org/active-model-adapter/-/active-model-adapter-2.1.1.tgz",

"resolved": "https://registry.npmjs.org/active-model-adapter/-/active-model-adapter-2.1.1.tgz"

},

"bootstrap-daterangepicker": {

"version": "2.1.21",

- "from": "[email protected]",

+ "from": "https://registry.npmjs.org/bootstrap-daterangepicker/-/bootstrap-daterangepicker-2.1.21.tgz",

"resolved": "https://registry.npmjs.org/bootstrap-daterangepicker/-/bootstrap-daterangepicker-2.1.21.tgz",

"dependencies": {

"jquery": {

"version": "3.1.1",

- "from": "[email protected]>=1.10.0",

+ "from": "https://registry.npmjs.org/jquery/-/jquery-3.1.1.tgz",

"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.1.1.tgz"

}

}

},

"bower": {

"version": "1.8.0",

- "from": "[email protected]",

+ "from": "https://registry.npmjs.org/bower/-/bower-1.8.0.tgz",

"resolved": "https://registry.npmjs.org/bower/-/bower-1.8.0.tgz"

},

"broccoli-asset-rev": {

"version": "2.5.0",

- "from": "[email protected]>=2.2.0 <3.0.0",

+ "from": "https://registry.npmjs.org/broccoli-asset-rev/-/broccoli-asset-rev-2.5.0.tgz",

"resolved": "https://registry.npmjs.org/broccoli-asset-rev/-/broccoli-asset-rev-2.5.0.tgz",

"dependencies": {

"broccoli-asset-rewrite": {

"version": "1.1.0",

- "from": "[email protected]>=1.1.0 <2.0.0",

+ "from": "https://registry.npmjs.org/broccoli-asset-rewrite/-/broccoli-asset-rewrite-1.1.0.tgz",

"resolved": "https://registry.npmjs.org/broccoli-asset-rewrite/-/broccoli-asset-rewrite-1.1.0.tgz"

Coming from a Ruby world with Bundler, I don't understand the logic behind this. Why should npm-shrinkwrap change between a URL and a name every time I run it? This makes npm-shrinkwrap.json impracticable for version control, in my opinion.

How can I make npm-shrinkwrap consistent and only use URLs or names?

相关阅读:
Top