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条回答
我命由我不由天
2楼-- · 2020-06-30 04:46

This happened to me on Intellij

For anyone else having this issue, did you copy your project from an existing project?

If so, close Intellij and delete the .idea folder. (You can delete node_modules too get a fresh start)

Open the project again and this will be resolved.

查看更多
贼婆χ
3楼-- · 2020-06-30 04:47

There was a syntax error in my package.json that was causing this for me!

查看更多
▲ chillily
4楼-- · 2020-06-30 04:49

I had the -g flag there, when I removed it, it worked as expected ...

查看更多
欢心
5楼-- · 2020-06-30 04:49

navigate to JSON file -> right click properties -> remove "read only" flag.

查看更多
ゆ 、 Hurt°
6楼-- · 2020-06-30 04:50

This can occur in VSCode (or probably other editors) if you have an unsaved package.json open.

The file was actually being updated but not reloaded in the IDE. I think maybe the default is to reload only if the file is unedited? Or maybe I clicked something to ignore warnings.

查看更多
女痞
7楼-- · 2020-06-30 04:53

With the accepted answer still my problem not resolve, then I try to change syntax position Previously I am using the following command to install the module to devDependencies

npm i --save-dev moduleName

Then I toggle the position of moduleName and --save-dev and the moduleName successfully added in the package.json file

npm i moduleName--save-dev

Then the the package.json file updated with the moduleName.

查看更多
登录 后发表回答