node.js 如何在 NPM 中更新 devDependencies?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10068592/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I update devDependencies in NPM?
提问by Matt
npm updateseems to just update the packages in dependencies, but what about devDependencies.
npm update似乎只是更新 中的包dependencies,但是devDependencies.
Right now you can install devDependenciesby running npm install ., but this doesn't work for npm update .
现在您可以devDependencies通过运行安装npm install .,但这不适用于npm update .
Any ideas?
有任何想法吗?
回答by deckerdev
To update package.json in addition to the local modules, run
除了本地模块之外,要更新 package.json,请运行
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>
回答by Michael Thompson
Install npm-check-updates (https://www.npmjs.org/package/npm-check-updates), then jump into your project folder and run:
安装 npm-check-updates ( https://www.npmjs.org/package/npm-check-updates),然后跳转到你的项目文件夹并运行:
npm-check-updates
And to update and save changes to your package.json file:
并更新并保存对 package.json 文件的更改:
npm-check-updates -u
回答by spieglio
This problem does no longer excise with the current version of NPM (1.3.11).
当前版本的 NPM (1.3.11) 不再存在此问题。
Update works fine with: npm update
更新适用于: npm update
回答by jmarceli
If you are using outdated npm version it might be the problem. So before any other commands execute:
如果您使用的是过时的 npm 版本,则可能是问题所在。所以在执行任何其他命令之前:
sudo npm install npm -g
or (if above doesn't work):
或(如果以上不起作用):
sudo npm update npm -g
Then relaunchthe console (in order for changes to take effect).
Now you can check your new npm --versionand if it is up to date execute:
然后重新启动控制台(以使更改生效)。现在您可以检查新的npm --version,如果它是最新的,请执行:
npm update
or (if you prefer):
或(如果您愿意):
npm update --save-dev
回答by Varsha
What worked for me is installing individual dev dependencies like this
对我有用的是安装这样的单个开发依赖项
npm install [email protected] --save --only=dev
回答by Gilad Peleg
I ran into the same problem as OP had, and found no solution, so I decided to write a Grunt plugin that will auto-update my devDependencies..
我遇到了与 OP 相同的问题,但没有找到解决方案,所以我决定编写一个 Grunt 插件来自动更新我的 devDependencies..
It's on Github, I'd love to get some input and collaborations in order to make it the best tool that NPM hasn't provided.
它在 Github 上,我很想得到一些意见和合作,以使其成为 NPM 未提供的最佳工具。
Basically it will auto-update your outdated development dependencies with a simple Grunt Task.
基本上它会通过一个简单的 Grunt 任务自动更新你过时的开发依赖项。
回答by Rick Deckard
One (slow) way to do force the update, is to remove the node_modules directory, and then do npm installagain.
强制更新的一种(缓慢)方法是删除 node_modules 目录,然后npm install再次执行。
This was a known bug of the npm updatecommand, which has been fixed on the development branch of npm, see here:
https://github.com/isaacs/npm/pull/3863
这是该npm update命令的一个已知错误,已在 的开发分支上修复npm,请参见此处:https:
//github.com/isaacs/npm/pull/3863
It should land on the latest stable version of npm pretty soon.
它应该很快就会登陆 npm 的最新稳定版本。
回答by Alferd Nobel
These steps worked for me :
这些步骤对我有用:
npm install -g npm-check-updatesncu -unpm updatenpm install
npm install -g npm-check-updatesncu -unpm updatenpm install

