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.

2楼-- · 2020-06-30 04:29

I have an .npmrc file that uses an npm api built in-house to fetch packages. My issue was that I was not connected to my company's VPN.

3楼-- · 2020-06-30 04:32

I had the same problem. When i installed some package, it was not shown on the package.json. So then I deleted the package.json file and ran npm init again. After that it was working and the packages I installed before was also there under dependencies.

The star\"
4楼-- · 2020-06-30 04:36

The only way I was able to solve this was by using npm install --save-dev moduleName instead of npm install moduleName --save-dev. Using npm install moduleName --save works fine for me, though. Only when I use --save-dev, I have to put it before the moduleName. I hope this helps anyone.

ゆ 、 Hurt°
5楼-- · 2020-06-30 04:37

I ran into this recently, and figured out that for whatever reason it was Atom that was preventing the file from updating, even without the file being open.

I closed the editor, re-ran my npm install, opened the editor again and everything was as it should be.

6楼-- · 2020-06-30 04:38

I tried all the commands stated in above answers but got success on installing npm-upgrade package.

npm i -g npm-upgrade then npm-upgrade

7楼-- · 2020-06-30 04:40

For me the issue was i copied the command from notepad++ it may have had special chars in there or it was the spaces, and it was not updating my package.json.

e.g. did not work; npm install --save debug pug jwt-simple method-override mongoose

Make sure when you install, you clean up the command line, e.g. any spaces between each module, because there might be special chars in there as well depending on your encoding.

When i corrected it to this it worked.

npm install --save debug pug jwt-simple method-override mongoose

Also, please make sure the package.json isn't opened in an editor when you run the command, because not all editors handle this gracefully.

登录 后发表回答