为什么npm-shrinkwrap每次都会在名称和URL之间翻转?

时间:2016-11-24 01:47:53

标签: node.js npm npm-shrinkwrap

使用:

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

步骤:

  • 我更新package.json
  • 删除我的所有模块:rm -fr node_modules
  • 重新安装所有内容:nvm exec npm install
  • 并更新shrinkwrap:nvm exec npm shrinkwrap --dev

结果:

每次,每个模块的from字段都会在名称和网址之间发生变化,如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-model-adapter@2.1.1",
+      "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": "bootstrap-daterangepicker@2.1.21",
+      "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": "jquery@>=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": "bower@1.8.0",
+      "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": "broccoli-asset-rev@>=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": "broccoli-asset-rewrite@>=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"

来自Bundler的Ruby世界,我不明白这背后的逻辑。每次运行时,为什么npm-shrinkwrap会在URL和名称之间发生变化?在我看来,这使npm-shrinkwrap.json对版本控制不可行。

如何使npm-shrinkwrap保持一致且仅使用网址或名称?

1 个答案:

答案 0 :(得分:1)

更多关于如何使用npm以及何时安装软件包。您可以阅读解释here