Are there simple or subtle reasons that package.json
would not update after running a --save-dev? This is my command:
npm install modulename --save-dev
Run from the root of the project. The command succeeds, the new module shows up in the node_modules directory as expected. Help would be appreciated. I am using npm v 1.4.28
The entirety of my current package.json
is:
{
"name": "FooWeb",
"version": "1.0.0",
"description": "Foo Web",
"devDependencies": {
"gulp": "3.8.11",
"gulp-jshint": "1.9.2",
"gulp-concat": "2.5.2",
"gulp-sass": "1.3.3",
"gulp-sourcemaps": "1.4.0",
"gulp-watch": "4.1.1"
}
}
I do get warnings on install of a package that I have no repository field or README, but I think that is not related.
After I used express generator I installed some packages with --s and none of them added to package.json.
Then I deleted the package.json and run npm init and all of them added without having to install again
Removing the dependency from devDependencies in package.json file and installing again using only --save worked for me
Mustafah ELBanna's answer helped me, but i want to expand his answer for other newbies like myself. Please correct me if I miss something important.
If you remove the
-g
flag, the module is not installed globally for your machine, but only locally in your project. If you also want it to install globally, execute the same command again but now with-g
instead of--save-dev
like this :npm install --save-dev [packagename]
npm install -g [packagename]
It seems to me that something might go wrong when calling
-g
and--save
in one line.But again, I'm new to this and I appreciate anyone who wants to improve/correct my answer.
I had this problem as well, and it was driving me crazy.
What finally fixed it was running
npm init
. This added a bunch of stuff to my package.json, but afterwards--save-dev
worked as expected. Even after I removed all the new stuff added bynpm init
,--save-dev
still worked.I was trying to install the gruntjs using "npm install --save grunt-sass" but the package.json won't update
I did everything mentioned above but no luck. But funny thing is if i try adding a package say "underscore (npm install --save underscore)" the son gets updated. I am not sure if this is a problem with the nam as such. I did install as a super user.
You may first want to check your config (
npm config ls
command or~/.npmrc
file). I hadlink=true
.In version 5.5.1, this option seems to be ignored when --save is active. Given that --save-dev supersedes --save, the link mode is active again.
So for me things happens as if
--save
overrided--link
which in turn overrided--save-dev
.