我只是设置了我的Gruntfile.js文件并加载了所有(9)devDependencies。要安装这些devDependencies,我使用了以下命令
npm install name-of-plugin --save-dev
我为每个依赖项使用了上面的命令9次。现在我想要的是使用一个命令来安装所有这些依赖项,如grunt install plugins
或其他命令。该命令将从package.json文件中读取devDependencies并为我安装。
这可能吗?如果是,那我该如何实现呢?
答案 0 :(得分:6)
您必须在deveDependencies
和package.json
npm install
<强>的package.json 强>
{
"name": "projectname",
"version": "0.0.1",
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-coffee": "~0.7.0",
"grunt-contrib-uglify": "~0.2.0",
"grunt-contrib-compass": "~0.5.0",
"grunt-contrib-jshint": "~0.6.0",
"grunt-contrib-cssmin": "~0.6.0",
"grunt-contrib-connect": "~0.5.0",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-htmlmin": "~0.1.3",
"grunt-contrib-imagemin": "~0.2.0",
"grunt-contrib-watch": "~0.5.2",
"grunt-contrib-jade": "*",
"grunt-autoprefixer": "~0.2.0",
"grunt-usemin": "~0.1.11",
"grunt-svgmin": "~0.2.0",
"grunt-rev": "~0.1.0",
"grunt-concurrent": "~0.3.0",
"load-grunt-tasks": "~0.1.0"
}
}
然后运行
npm install
答案 1 :(得分:1)
如果您知道您的依赖关系名称,那么您可以尝试这样 -
npm install grunt-contrib-sass grunt-contrib-uglify --save