can't use last Express version - node.js

I want to update to the last Express version in my project, but seems to be impossible.
Last stable version is 4.13.4:
If I run npm list express -g to check my global version installed, I have:
$ npm list express -g
C:\Users\User\AppData\Roaming\npm
+-- express#4.13.4
But if I run npm express -v, the output is:
3.8.3
If I open package.json, it has:
//...
"dependencies": {
"bcrypt": "^0.7.7",
"body-parser": "^1.15.0",
"escape-html": "^1.0.3",
"express": "^4.13.4",
"jade": "*",
"method-override": "^2.3.5",
"moment": "^2.12.0",
"mongoose": "^3.8.8",
"node-mysql": "^0.4.2",
"node-oauth2-server": "^2.0.2"
},
//...
No matter if I run npm install or npm install express#4.13.4, output for npm express -v is 3.8.3.
Could be possible that other module is forcing to not update Express to 4.*? How could I confirm that?
Thanks!

Related

node-pre-gyp ERR! Tried to download(404) while migration in windows 10

May be this question already asked but that's not solving my issue.
I try to migrate my Node.Js project one system to another one system, that time application shows bcrypt error while npm install. Error is following:
package.json:
"dependencies": {
"aws-sdk": "^2.325.0",
"bcrypt": "^2.0.1",
"bluebird": "^3.5.1",
"compression": "^1.0.3",
"cors": "^2.5.2",
"crypto-js": "^3.1.9-1",
"date-and-time": "^0.6.2",
"date-fns": "^1.29.0",
"dateformat": "^3.0.2",
"generate-password": "^1.5.1",
"get-mac-address": "^1.0.0",
}
help me to solve this issue.
You could try
npm --build-from-source install bcrypt
or
npm install --global --production windows-build-tools
before installing the package.json.
Hope this might work.

npm install myPackage -g, Error: Cannot find module 'commander'

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

Hi. I am new to react and have a query re optimum setup procedures

The following package.json contains a lot of dependencies and a few devDependencies stuff but barring a few files it seems to have all I need excepting a few npm install commands for reactstrap, bootstrap, react-bootstrap
{
"name": "react-tutorials",
"version": "0.0.0",
"description": "",
"main": "webpack.config.js",
"dependencies": {
"babel-core": "^6.18.2",
"babel-loader": "^6.2.0",
"babel-plugin-add-module-exports": "^0.1.2",
"babel-plugin-react-html-attrs": "^2.0.0",
"babel-plugin-transform-class-properties": "^6.3.13",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"babel-preset-stage-0": "^6.3.13",
"flux": "^2.1.1",
"history": "^1.17.0",
"react": "^0.14.6",
"react-dom": "^0.14.6",
"react-router": "^1.0.3",
"webpack": "^1.12.9",
"webpack-dev-server": "^1.14.1"
},
"devDependencies": {},
"scripts": {
"dev": "webpack-dev-server --content-base src --inline --hot"
},
"author": "",
"license": "ISC"
}
// Additional dependencies and devDependencies
npm install --save reactstrap react-addons-transition-group react-addons-css-transition-group react react-dom
npm install react react-dom bootstrap react-bootstrap babel-preset-react webpack webpack-dev-server --save
npm install webpack css-loader style-loader file-loader url-loader babel-core
What is the optimal way to create a file tree for your react project via npm and what react-*** setup packages are not too difficult for a novice such as myself? Please don't suggest create-react-app - I love it but its limited. Also, can all dependencies and devDependencies be installed via npm all at once or with some files interfere with others which I've noticed before I think.
When you run each of the commands npm install --save package-here it will add that package to your package.json automatically. When you're ready to install your project from the root directory you run npm install only and it will install everything in your package.json into a node_modules folder. Other than that you should not have to change anything with your packages as far as file structure.
In addition, when you want to add a package to your dev-devependencies run npm install --save-dev or just dependencies npm install --save.

NPM in Windows not installing module or adding to package.json

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.*",

package.json add "npm install -g" to scripts preinstall

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)

Resources