I have a project that uses Angular2, webpack, and NPM on Windows. I am experiencing this on both v4.2.0 and v5.3.0 of NPM.
It appears sometimes I get the official jquery package and my build works. Othertimes I get an unofficial package from coolaj86 and then my build breaks with missing dependencies.
Even if I only use npm install git://github.com/jquery/jquery.git#f5416725afef
to install directly from the official repo, I still randomly get either package (and sometimes 1.7.4).
I can sit and run the same npm install command over and over and it will randomly rotate through different actual packages installed. I'm so confused..
It could also be related to a jquery-color package I use depending on jQuery (note the capital 'Q') 1.7.4 because that also sometimes ends up being the jquery package I get in node_modules
.
In my package.json
I reference jquery (I have also tried git://github.com/jquery/jquery.git#f5416725afef
here):
"jquery": "2.2.4"
Sometimes my node_modules\jquery\package.json
file is this, and the build works. This appears to be the official package.
{
"_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"
}
Other time my node_modules\jquery\package.json
file is this, and the build breaks with missing dependencies. This appears to be the unofficial build from 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"
}
If I call npm install
multiple times, it will often switch to the other jquery package, but not always, and this is making continuous integration impossible. Is there any way I can force npm to install the official package every time? Or to redirect dependencies on jQuery to the later jquery package?
Currently I'm clobbering the node_modules\jquery directory with a zipped up copy I took at a point when I had the right one. It works, but yuck.
Here is the output of 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.
Here's the entire package.json
for my project:
{
"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"
}
}