I came across a nodejs repo that included npm in devdependencies. What would be the case that requires such config? Because, installing devdependencies already requires npm.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
This makes sense if a repository uses NPM CLI internally and relies on specific NPM version instead of globally installed NPM, because the behaviour may be changed between major releases:
devDependencies: {
"npm": "^2"
}
While
devDependencies: {
"npm": "*"
}
won't make much sense, except that it will likely use latest stable NPM version, despite which version was installed globally on local system.
This also makes sense if NPM is used programmatically because global packages cannot be normally require
d.
回答2:
Modules which is required for your local development and does not required for production environment can be listed under devDependencies. Its is good to have devDependencies.
- npm install will install both "dependencies" and "devDependencies"
- npm install --production will only install "dependencies"
- npm install --dev will only install "devDependencies"