冲突的jquery NPM包

时间:2017-07-31 00:25:11

标签: jquery node.js npm npm-install

我有一个在Windows上使用Angular2,webpack和NPM的项目。我在NPM的v4.2.0和v5.3.0上都遇到过这种情况。

有时候我会得到官方的jquery包,我的构建工作正常。 Othertimes我从coolaj86得到一个非正式的包,然后我的构建中断了缺少的依赖。

即使我只使用npm install git://github.com/jquery/jquery.git#f5416725afef直接从官方仓库安装,我仍然随机获得任一包(有时是1.7.4)。

我可以一遍又一遍地运行相同的npm install命令,它将随机旋转通过安装的不同实际包。我很困惑..

它也可能与我使用的jquery-color包有关,这取决于jQuery(注意大写'Q')1.7.4因为它有时最终成为我在node_modules中得到的jquery包。 / p>

在我的package.json我引用jquery(我在这里也试过git://github.com/jquery/jquery.git#f5416725afef):

"jquery": "2.2.4"

有时我的node_modules\jquery\package.json文件就是这个,并且构建工作正常。这似乎是官方的一揽子计划。

{
  "_args": [
    [
      {
        "raw": "jquery@2.2.4",
        "scope": null,
        "escapedName": "jquery",
        "name": "jquery",
        "rawSpec": "2.2.4",
        "spec": "2.2.4",
        "type": "version"
      },
      "C:\\dev\\MyProject"
    ]
  ],
  "_from": "jquery@2.2.4",
  "_id": "jquery@2.2.4",
  "_inCache": true,
  "_location": "/jquery",
  "_nodeVersion": "0.10.45",
  "_npmOperationalInternal": {
    "host": "packages-16-east.internal.npmjs.com",
    "tmp": "tmp/jquery-2.2.4.tgz_1463765166836_0.5834389675874263"
  },
  "_npmUser": {
    "name": "timmywil",
    "email": "timmywillisn@gmail.com"
  },
  "_npmVersion": "2.15.1",
  "_phantomChildren": {},
  "_requested": {
    "raw": "jquery@2.2.4",
    "scope": null,
    "escapedName": "jquery",
    "name": "jquery",
    "rawSpec": "2.2.4",
    "spec": "2.2.4",
    "type": "version"
  },
  "_requiredBy": [
    "/",
    "/bootstrap-colorpicker",
    "/ion-rangeslider",
    "/jquery-validation"
  ],
  "_resolved": "https://registry.npmjs.org/jquery/-/jquery-2.2.4.tgz",
  "_shasum": "2c89d6889b5eac522a7eea32c14521559c6cbf02",
  "_shrinkwrap": null,
  "_spec": "jquery@2.2.4",
  "_where": "C:\\dev\\MyProject",
  "author": {
    "name": "jQuery Foundation and other contributors",
    "url": "https://github.com/jquery/jquery/blob/2.2.4/AUTHORS.txt"
  },
  "bugs": {
    "url": "https://github.com/jquery/jquery/issues"
  },
  "commitplease": {
    "components": [
      "Docs",
      "Tests",
      "Build",
      "Release",
      "Core",
      "Ajax",
      "Attributes",
      "Callbacks",
      "CSS",
      "Data",
      "Deferred",
      "Deprecated",
      "Dimensions",
      "Effects",
      "Event",
      "Manipulation",
      "Offset",
      "Queue",
      "Selector",
      "Serialize",
      "Traversing",
      "Wrap"
    ]
  },
  "dependencies": {},
  "description": "JavaScript library for DOM operations",
  "devDependencies": {
    "commitplease": "2.0.0",
    "core-js": "0.9.17",
    "grunt": "0.4.5",
    "grunt-babel": "5.0.1",
    "grunt-cli": "0.1.13",
    "grunt-compare-size": "0.4.0",
    "grunt-contrib-jshint": "0.11.2",
    "grunt-contrib-uglify": "0.9.2",
    "grunt-contrib-watch": "0.6.1",
    "grunt-git-authors": "2.0.1",
    "grunt-jscs": "2.1.0",
    "grunt-jsonlint": "1.0.4",
    "grunt-npmcopy": "0.1.0",
    "gzip-js": "0.3.2",
    "jsdom": "5.6.1",
    "load-grunt-tasks": "1.0.0",
    "qunit-assert-step": "1.0.3",
    "qunitjs": "1.17.1",
    "requirejs": "2.1.17",
    "sinon": "1.10.3",
    "sizzle": "2.2.1",
    "strip-json-comments": "1.0.3",
    "testswarm": "1.1.0",
    "win-spawn": "2.0.0"
  },
  "directories": {},
  "dist": {
    "shasum": "2c89d6889b5eac522a7eea32c14521559c6cbf02",
    "tarball": "https://registry.npmjs.org/jquery/-/jquery-2.2.4.tgz"
  },
  "gitHead": "c0185ab7c75aab88762c5aae780b9d83b80eda72",
  "homepage": "http://jquery.com",
  "keywords": [
    "jquery",
    "javascript",
    "browser",
    "library"
  ],
  "license": "MIT",
  "main": "dist/jquery.js",
  "maintainers": [
    {
      "name": "dmethvin",
      "email": "dave.methvin@gmail.com"
    },
    {
      "name": "scott.gonzalez",
      "email": "scott.gonzalez@gmail.com"
    },
    {
      "name": "m_gol",
      "email": "m.goleb@gmail.com"
    },
    {
      "name": "timmywil",
      "email": "timmywillisn@gmail.com"
    }
  ],
  "name": "jquery",
  "optionalDependencies": {},
  "readme": "ERROR: No README data found!",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/jquery/jquery.git"
  },
  "scripts": {
    "build": "npm install && grunt",
    "start": "grunt watch",
    "test": "grunt && grunt test"
  },
  "title": "jQuery",
  "version": "2.2.4"
}

其他时间我的node_modules\jquery\package.json文件是这样的,并且构建中断了缺少的依赖项。这似乎是coolaj86的非正式构建。

{
  "__dependencies": {
    "jsdom": "~0.2.14",
    "htmlparser": "1.7.6",
    "xmlhttprequest": "~1.4.2",
    "location": "0.0.1",
    "navigator": "~1.0.1"
  },
  "__devDependencies": {
    "grunt": "~0.3.8",
    "nodeunit": "~0.7.4"
  },
  "_args": [
    [
      "jquery@2.2.4",
      "C:\\dev\\MyProject"
    ]
  ],
  "_from": "jquery@2.2.4",
  "_id": "jquery@2.2.4",
  "_inBundle": false,
  "_integrity": "sha1-LInWiJterFIqfuoywUUhVZxsvwI=",
  "_location": "/jquery",
  "_phantomChildren": {},
  "_requested": {
    "type": "version",
    "registry": true,
    "raw": "jquery@2.2.4",
    "name": "jquery",
    "escapedName": "jquery",
    "rawSpec": "2.2.4",
    "saveSpec": null,
    "fetchSpec": "2.2.4"
  },
  "_requiredBy": [
    "/",
    "/bootstrap-colorpicker",
    "/ion-rangeslider",
    "/jquery-validation"
  ],
  "_resolved": "https://registry.npmjs.org/jquery/-/jquery-2.2.4.tgz",
  "_spec": "2.2.4",
  "_where": "C:\\dev\\MyProject",
  "author": {
    "name": "James Morrin",
    "email": "treasonx@gmail.com"
  },
  "bugs": {
    "url": "https://github.com/coolaj86/node-jquery/issues"
  },
  "description": "jQuery: The Write Less, Do More, JavaScript Library (packaged for Node.JS)",
  "engines": {
    "node": ">=0.6"
  },
  "homepage": "https://github.com/coolaj86/node-jquery",
  "keywords": [
    "util",
    "dom",
    "jquery"
  ],
  "licenses": [
    {
      "type": "MIT",
      "url": "https://github.com/coolaj86/node-jquery/blob/master/LICENSE-MIT"
    }
  ],
  "main": "lib/node-jquery",
  "name": "jquery",
  "repository": {
    "type": "git",
    "url": "git://github.com/coolaj86/node-jquery.git"
  },
  "scripts": {
    "test": "grunt test"
  },
  "url": "http://jquery.com",
  "version": "2.2.4"
}

如果我多次调用npm install,它通常会切换到另一个jquery包,但并非总是如此,这使得持续集成变得不可能。我有什么方法可以强迫npm每次都安装官方套餐吗?或者将jQuery的依赖项重定向到以后的jquery包?

目前我正在破坏node_modules \ jquery目录,其中包含我在合适时使用的压缩副本。它有效,但很糟糕。

以下是npm config list的输出:

; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/5.3.0 node/v8.2.1 win32 x64"

; builtin config undefined
prefix = "C:\\Users\\[username]\\AppData\\Roaming\\npm"

; node bin location = C:\Program Files\nodejs\node.exe
; cwd = F:\BuildAgent1\work\5a4db8c598978904\Web\MyProject
; HOME = C:\Users\[username]
; "npm config ls -l" to show all defaults.

以下是我项目的整个package.json

{
  "name": "my-project",
  "version": "1.1.0",
  "private": true,
  "scripts": {
    "build:vendor": "./node_modules/.bin/webpack --config webpack.config.vendor.js  --progress --profile --bail --env.prod",
    "build:vendor:dev": "./node_modules/.bin/webpack --config webpack.config.vendor.js  --progress --profile",
    "build:prod": "./node_modules/.bin/webpack --config webpack.config.js  --progress --profile --bail --env.prod",
    "build:dev": "./node_modules/.bin/webpack --config webpack.config.js  --progress --profile",
    "build": "npm run build:dev",
    "prebuild:prod": "npm run build:vendor"
  },
  "dependencies": {
    "@angular/common": "2.4.7",
    "@angular/compiler": "2.4.7",
    "@angular/core": "2.4.7",
    "@angular/forms": "2.4.7",
    "@angular/http": "2.4.7",
    "@angular/platform-browser": "2.4.7",
    "@angular/platform-browser-dynamic": "2.4.7",
    "@angular/router": "3.4.7",
    "@angularclass/hmr": "1.2.2",
    "@angularclass/hmr-loader": "3.0.2",
    "@types/hammerjs": "2.0.34",
    "@types/jasmine": "2.5.41",
    "@types/node": "6.0.63",
    "@types/selenium-webdriver": "2.53.33",
    "@types/source-map": "0.1.29",
    "@types/uglify-js": "2.6.28",
    "@types/webpack": "1.12.36",
    "X-editable": "git://github.com/vitalets/x-editable",
    "angular-in-memory-web-api": "0.2.4",
    "angular-router-loader": "0.4.0",
    "angular2-platform-node": "2.0.11",
    "angular2-template-loader": "0.6.2",
    "aspnet-webpack": "1.0.27",
    "assets-webpack-plugin": "3.5.1",
    "awesome-typescript-loader": "3.0.3",
    "bootstrap": "3.3.7",
    "bootstrap-colorpicker": "2.5.1",
    "bootstrap-duallistbox": "git://github.com/istvan-ujjmeszaros/bootstrap-duallistbox",
    "bootstrap-markdown": "2.10.0",
    "bootstrap-progressbar": "0.9.0",
    "bootstrap-slider": "9.7.1",
    "bootstrap-tagsinput": "0.7.1",
    "bootstrap-timepicker": "0.5.2",
    "chart.js": "2.3.0",
    "clean-webpack-plugin": "0.1.15",
    "clockpicker": "0.0.7",
    "clone": "2.0.0",
    "codelyzer": "1.0.0-beta.4",
    "copy-webpack-plugin": "4.0.1",
    "core-js": "2.4.1",
    "css": "2.2.1",
    "css-loader": "0.26.1",
    "debounce": "1.0.0",
    "dropzone": "4.3.0",
    "dygraphs": "1.1.1",
    "es6-shim": "0.35.3",
    "exports-loader": "0.6.3",
    "expose-loader": "0.7.1",
    "extract-text-webpack-plugin": "2.0.0-rc.3",
    "file-loader": "0.9.0",
    "fuelux": "3.15.11",
    "gh-pages": "0.12.0",
    "he": "1.1.1",
    "highcharts": "4.2.7",
    "html-minify-loader": "1.1.0",
    "html-webpack-plugin": "2.28.0",
    "ie-shim": "0.1.0",
    "imports-loader": "0.6.5",
    "ion-rangeslider": "2.1.6",
    "isomorphic-fetch": "2.2.1",
    "istanbul-instrumenter-loader": "0.2.0",
    "jquery": "2.2.4",
    "jquery-color": "1.0.0",
    "jquery-jcrop": "0.9.13",
    "jquery-knob": "1.2.11",
    "jquery-ui-npm": "1.12.0",
    "jquery-validation": "1.16.0",
    "jquery.maskedinput": "1.4.1",
    "json-loader": "0.5.4",
    "karma": "1.4.1",
    "karma-chrome-launcher": "2.0.0",
    "karma-coverage": "1.1.1",
    "karma-jasmine": "1.1.0",
    "karma-mocha-reporter": "2.2.2",
    "karma-remap-coverage": "0.1.4",
    "karma-sourcemap-loader": "0.3.7",
    "karma-webpack": "1.8.0",
    "markdown": "0.5.0",
    "morris.js": "0.5.0",
    "ng2-bootstrap": "1.3.3",
    "ng2-popover": "0.0.13",
    "ng2-redux": "4.2.1",
    "nouislider": "8.5.1",
    "oidc-client": "1.3.0",
    "parse5": "2.2.3",
    "protractor": "4.0.14",
    "raphael": "2.2.7",
    "raw-loader": "0.5.1",
    "redux": "3.6.0",
    "reflect-metadata": "0.1.9",
    "rimraf": "2.5.4",
    "rxjs": "5.1.0",
    "script-ext-html-webpack-plugin": "1.7.1",
    "script-loader": "0.7.0",
    "scriptjs": "2.5.8",
    "select2": "4.0.3",
    "smartadmin-plugins": "1.0.15",
    "source-map-loader": "0.1.6",
    "string-replace-loader": "1.0.5",
    "style-loader": "0.13.1",
    "summernote": "0.8.2",
    "to-markdown": "3.0.3",
    "to-string-loader": "1.1.5",
    "ts-helpers": "1.1.2",
    "ts-loader": "0.8.2",
    "ts-node": "1.7.3",
    "tslint": "3.15.1",
    "tslint-loader": "2.1.5",
    "typedoc": "0.5.5",
    "typescript": "2.1.6",
    "underscore": "1.8.3",
    "url-loader": "0.5.7",
    "v8-lazy-parse-webpack-plugin": "0.3.0",
    "webpack": "2.2.1",
    "webpack-hot-middleware": "2.16.1",
    "webpack-md5-hash": "0.0.5",
    "webpack-merge": "1.0.2",
    "zone.js": "0.7.6"
  }
}

0 个答案:

没有答案