How do I update devDependencies in NPM?

前端 未结 8 2043
长发绾君心
长发绾君心 2020-12-12 10:52

npm update seems to just update the packages in dependencies, but what about devDependencies.

Right now you can install

相关标签:
8条回答
  • 2020-12-12 11:35

    This problem does no longer excise with the current version of NPM (1.3.11).

    Update works fine with: npm update

    0 讨论(0)
  • 2020-12-12 11:35

    If you are using outdated npm version it might be the problem. So before any other commands execute:

    sudo npm install npm -g
    

    or (if above doesn't work):

    sudo npm update npm -g
    

    Then relaunch the console (in order for changes to take effect). Now you can check your new npm --version and if it is up to date execute:

    npm update
    

    or (if you prefer):

    npm update --save-dev
    
    0 讨论(0)
  • 2020-12-12 11:38

    One (slow) way to do force the update, is to remove the node_modules directory, and then do npm install again.

    This was a known bug of the npm update command, which has been fixed on the development branch of npm, see here: https://github.com/isaacs/npm/pull/3863

    It should land on the latest stable version of npm pretty soon.

    0 讨论(0)
  • 2020-12-12 11:43

    To update package.json in addition to the local modules, run

    npm update --save-dev
    

    Alternatively, the same command to save time

    npm update -D
    

    You can view the full detail of update, or any command for that matter through

    npm help <cmd>
    
    0 讨论(0)
  • 2020-12-12 11:49

    What worked for me is installing individual dev dependencies like this

    npm install react-test-renderer@15.6.1 --save --only=dev
    
    0 讨论(0)
  • 2020-12-12 11:58

    Install npm-check-updates (https://www.npmjs.org/package/npm-check-updates), then jump into your project folder and run:

    npm-check-updates
    

    And to update and save changes to your package.json file:

    npm-check-updates -u
    
    0 讨论(0)
提交回复
热议问题