npm install packagename --save-dev not updating pa

2020-06-30 03:51发布

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.

18条回答
Deceive 欺骗
2楼-- · 2020-06-30 04:40

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

查看更多
smile是对你的礼貌
3楼-- · 2020-06-30 04:42

Removing the dependency from devDependencies in package.json file and installing again using only --save worked for me

查看更多
爷的心禁止访问
4楼-- · 2020-06-30 04:43

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-devlike 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.

查看更多
姐就是有狂的资本
5楼-- · 2020-06-30 04:45

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 by npm init, --save-dev still worked.

查看更多
爱情/是我丢掉的垃圾
6楼-- · 2020-06-30 04:45

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.

查看更多
太酷不给撩
7楼-- · 2020-06-30 04:45

You may first want to check your config (npm config ls command or ~/.npmrc file). I had link=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.

查看更多
登录 后发表回答