In my package.json, I have:
"devDependencies": {
"download": "^0.1.18",
"grunt": "^0.4.5",
"grunt-autoprefixer": "^0.8.0",
"grunt-contrib-imagemin": "^0.7.1",
"grunt-contrib-less": "^0.11.3",
"grunt-contrib-requirejs": "^0.4.4",
"grunt-contrib-watch": "^0.6.1"
}
When I run npm install, it tries to install grunt-contrib-imagemin before anything else and it throws an error.
The workaround is to npm install download, THEN npm install grunt-contrib-imagemin manually, then npm install the rest of the packages.
Why doesn't npm install respect the order of the packages listed in devDependencies?
Related
I am Chinese, my English is not good.
I submit a npm package,this package dependent on commander, i sure the commander had install.
Then i install my package, when i use it, the console show 'Error: Cannot find module 'commander', i'm confused.
this is code:
"devDependencies": {
"chalk": "^2.4.1",
"commander": "^2.15.1",
"download-git-repo": "^1.0.2",
"handlebars": "^4.0.11",
"inquirer": "^6.0.0",
"log-symbols": "^2.2.0",
"ora": "^2.1.0"
}
when i npm install -g my package,the 'commander' could not be found:
https://i.stack.imgur.com/KpDzt.png
I have no idea why I get an error for mongoskin. I used this module before but I got rid of it. I removed the node_modules directory then did a fresh npm install, fine everything installs. Then I tried to add a new module minimist as seen below:
C:\www\instantynode\src>npm install minimist --save
npm WARN package.json instanty#0.1.1 No description
npm WARN package.json instanty#0.1.1 No repository field.
npm WARN package.json instanty#0.1.1 No README data
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "minimist" "--save"
npm ERR! node v4.4.0
npm ERR! npm v2.14.20
npm ERR! code EPEERINVALID
npm ERR! peerinvalid The package mongodb#2.1.4 does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer mongoskin#1.4.13 wants mongodb#~1.4
npm ERR! Please include the following file with any support request:
npm ERR! C:\www\instantynode\src\npm-debug.log
package.json:
{
"name": "app",
"version": "0.1.1",
"description": "",
"dependencies": {
"bunyan": "1.5.1",
"co": "4.6.0",
"cookie-parser": "^1.4.0",
"forever": "^0.15.1",
"fs": "0.0.2",
"geoip-lite": "^1.1.6",
"handlebars": "^4.0.5",
"jsonwebtoken": "^5.4.1",
"jwt-simple": "^0.4.0",
"koa": "^1.1.2",
"koa-better-ratelimit": "^2.1.2",
"koa-bodyparser": "^2.0.1",
"koa-conditional-get": "^1.0.3",
"koa-generic-session": "^1.10.0",
"koa-handlebars": "^0.5.7",
"koa-mount": "^1.3.0",
"koa-multer": "1.0.0",
"koa-passport": "^2.0.1",
"koa-redis": "^1.0.1",
"koa-router": "^5.3.0",
"koa-static": "^1.5.2",
"lodash": "^3.10.1",
"mongodb": "2.1.4",
"nodemailer": "2.1.0",
"nodemon": "^1.8.1",
"passport": "^0.3.2",
"passport-http-bearer": "^1.0.1",
"passport-local": "^1.0.0",
"socket.io": "^1.3.7",
"socketio-jwt": "^4.3.3"
},
"devDependencies": {
"assert": "1.3.0",
"del": "2.1.0",
"gulp": "^3.9.1",
"gulp-autoprefixer": "3.1.0",
"gulp-concat": "2.6.0",
"gulp-concat-css": "2.2.0",
"gulp-imagemin": "2.4.0",
"gulp-less": "3.0.5",
"gulp-minify-css": "1.2.2",
"gulp-notify": "2.2.0",
"gulp-uglify": "1.5.1",
"imagemin-pngquant": "4.2.0",
"jsdoc": "3.4.0",
"node-inspector": "0.12.5",
"run-sequence": "1.1.5"
},
"main": "app.js",
"scripts": {
"startfn": "forever start -c \"nodemon --harmony\" app.js --exitcrash",
"startf": "forever start -c \"node --harmony\" app.js",
"start": "node --harmony app.js"
},
"author": "",
"license": "ISC"
}
npm install minimist --save does not work as you can see, does not install or add itself to the package.json file. And it is still mentioning mongoskin?
I have a feeling that the NPM in Windows is buggy?
i think that mongoskin only work with mongodb driver older than 1.4. You might have installed mongoskin in global mode, try to remove it.
You are trying to install minimist, which has its own package.json with its own dependencies. In these it says that it wants mongoskin to be installed, which has a dependency on mongodb itself, but in another version than you have it (you have 2.1.4 but as the error says, it needs ~1.4).
So, because you provided the --save parameter, you want npm to respect these dependencies and do not install mongodb in the desired version on top of it.
Ok I've found the issue. The NPM in Windows is way more sensitive than the one in Linux. In Linux I can manually remove the line from the package.json file and just remove the node_modules directory. However in Windows it appears to be cached by NPM, so I had to manually use the npm remove mongoskin --save command.
When I did this so that the package.json looked like it should I was able to install minimist via npm install minimist --save without issues!
I'm not surprised Windows... Not surprised...
In your package.json, try to change this:
"mongodb": "2.1.4",
to this:
"mongodb": "1.4.*",
I try to install time-grunt local and global, clear npm cache, update npm, but nothing helps.
I get:
Loading "Gruntfile.js" tasks...ERROR
Error: Cannot find module 'time-grunt'
Warning: Task "default" not found. Use --force to continue.
My version of packages:
node: '0.10.31',
npm: '1.4.23'
After run:
npm install --save-dev time-grunt
in package.json state:
"devDependencies": {
"grunt": "^0.4.5",
...
"time-grunt": "^1.0.0"
}
This is part of my grunfile.js:
module.exports = function( grunt ) {
require('time-grunt')(grunt);
grunt.initConfig({
// grunt tasks here
});
// load tasks here
// register task here
}
Other grunt tasks running without error.
I'm not understand what is wrong.
How I can test correctly installation of time-grunt by CLI?
You need to add it inside dependencies and not within devDependencies. This way you don't need to separately run $ npm install --save-dev time-grunt
{
"name": "grunt-build",
"version": "0.1.0",
"private": true,
"dependencies": {
"time-grunt": "^1.3.0"
},
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-clean": "~0.7.0",
"grunt-contrib-compress": "~0.5.0",
"grunt-contrib-concat": "~0.5.0",
"grunt-contrib-copy": "^0.8.0",
"grunt-contrib-uglify": "~0.5.0",
"grunt-remove-logging": "~0.2.0"
}
}
use npm install or sudo npm install in the folder with package.json
I ended up installing all grunt dependencies manually.
npm install time-grunt
npm install load-grunt-config
and then all modules listed here:
Note: you can install all of the dependencies in the photo above in one go with npm install.
Finally I ran the grunt command and it worked!
When writing package.json:
"scripts": {
"preinstall": "npm install -g grunt-cli"
},
"devDependencies": {
"async": "^0.9.0",
"grunt": "^0.4.5",
"grunt-contrib-connect": "^0.9.0",
"grunt-contrib-cssmin": "^0.10.0",
"grunt-contrib-jshint": "^0.10.0",
"grunt-contrib-uglify": "^0.6.0",
"grunt-contrib-watch": "^0.6.1",
"jit-grunt": "^0.9.0",
"marked": "^0.3.2",
"time-grunt": "^1.0.0",
"underscore": "^1.7.0"
}
And then running the command npm install
It works on some computers but on some I get this error:
http://pastebin.com/rYUwhV5k
Is it proper use of the package.json?
Is there any other way to do it?
How can I fix the problem that occurs on the other computers?
According to the npm documentation "NOTE: INSTALL SCRIPTS ARE AN ANTIPATTERN"
https://docs.npmjs.com/misc/scripts
In your case, probably best to just add in the readme.md that you need to have grunt installed to run the tests (and let the user decides how to install it)
My issue appears after (or even during) the creation of the angular project with the command:
yo angular
during the process of installing all the devDependencies from the package.json ("npm install" which yo angular runs) I notice that some modules are missing in the node_modules folder.
So, I downloaded after that again with the "npm install name_of_the_module --save-dev" (so they will download and be included in the package.json in the devDependencies option).
But for example If I remove the node_modules folder and I execute the command npm install it will start the installation but will miss some modules, and sometimes the missing modules are different from the last run of npm install.
I don't know how to face this because I need to set up the project for the team and the first thing they will have to do is executing npm install & bower install (this last one works fine).
The content of package.json is:
{
"name": "angular_test",
"version": "0.0.0",
"dependencies": {},
"devDependencies": {
"grunt": "^0.4.5",
"grunt-autoprefixer": "^0.7.6",
"grunt-concurrent": "^0.5.0",
"grunt-contrib-clean": "^0.5.0",
"grunt-contrib-concat": "^0.4.0",
"grunt-contrib-connect": "^0.7.1",
"grunt-contrib-copy": "^0.5.0",
"grunt-contrib-cssmin": "^0.9.0",
"grunt-contrib-htmlmin": "^0.3.0",
"grunt-contrib-imagemin": "^0.8.1",
"grunt-contrib-jshint": "^0.10.0",
"grunt-contrib-uglify": "^0.4.1",
"grunt-contrib-watch": "^0.6.1",
"grunt-filerev": "^0.2.1",
"grunt-google-cdn": "^0.4.0",
"grunt-karma": "^0.9.0",
"grunt-newer": "^0.7.0",
"grunt-ng-annotate": "^0.3.2",
"grunt-svgmin": "^0.4.0",
"grunt-usemin": "^2.4.0",
"grunt-wiredep": "^1.7.0",
"imagemin-jpegtran": "^2.0.0",
"imagemin-pngquant": "^2.0.0",
"jshint-stylish": "^0.2.0",
"karma": "^0.12.24",
"karma-jasmine": "^0.1.5",
"karma-phantomjs-launcher": "^0.1.4",
"load-grunt-tasks": "^0.6.0",
"time-grunt": "^0.3.2"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "grunt test"
}
}
and the errors or log I get after executing npm install is:
npm WARN optional dep failed, continuing imagemin-optipng#1.0.0
npm WARN optional dep failed, continuing http-signature#0.10.0
npm WARN optional dep failed, continuing imagemin-jpegtran#1.0.0
npm WARN optional dep failed, continuing imagemin-pngquant#1.0.2
npm WARN optional dep failed, continuing imagemin-gifsicle#1.0.0
npm ERR! EEXIST, open 'C:\Users\myself\AppData\Roaming\npm-cache\78af9c6a-m-cache-lodash-2-4-1-package-tgz.lock'
File exists: C:\Users\myself\AppData\Roaming\npm-cache\78af9c6a-m-cache-lodash-2-4-1-package-tgz.lock
Move it away, and try again.
npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd C:\Users\myself\Documents\PHPStorm_Workspace\angular_test
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! path C:\Users\myself\AppData\Roaming\npm-cache\78af9c6a-m-cache-lodash-2-4-1-package-tgz.lock
npm ERR! code EEXIST
npm ERR! errno 47
npm ERR! not ok code 0
UPDATE
All these issues appear because of "npm" so after researching a little bit, the creator of npm suggested to download the last version, which is only available either...
npm install -g npm#next
or
npm install -g npm#2.1.2 (in this case is only for the current release 2.1.2, which is the latest release)
or
Downloading the source and copying its content where npm is installed (inside the node_modules folder where you installed node.js):
https://www.versioneye.com/nodejs/npm/2.1.2
When I find the github discussion I will update the post with it.
This is bug and can be fixed by update your npm version (https://github.com/npm/npm/issues/6318).
Try: npm -g install npm#next
File exists:
C:\Users\myself\AppData\Roaming\npm-cache\78af9c6a-m-cache-lodash-2-4-1-package-tgz.lock
Move it away, and try again.
It seems like npm is resolvng from your cache, try # npm cache clear (for more info) to make sure a package isn’t loading anything from npm’s cache.
Most likely due to this bug in npm.