我刚刚开始使用Grunt.js。它很难设置,我正在创建一个包。json文件。

在本教程中,有3种方法可以创建包。json文件。

第一个是执行npm install grunt——save-dev

但是——save-dev是什么意思呢?我试过找,但没有结果。


当前回答

当你使用参数"——save"时,你的依赖项将在package.json的#1中。当你使用参数"——save-dev"时,你的依赖项将在package.json的#2中。

# 1。"dependencies":这些包是生产应用程序所需要的。

# 2。“devDependencies”:这些包只在开发和测试时需要

其他回答

您可以在包中指定(至少)两种类型的包依赖关系。json文件:

Those packages that are required in order to use your module are listed under the "dependencies" property. Using npm you can add those dependencies to your package.json file this way: npm install --save packageName Those packages required in order to help develop your module are listed under the "devDependencies" property. These packages are not necessary for others to use the module, but if they want to help develop the module, these packages will be needed. Using npm you can add those devDependencies to your package.json file this way: npm install --save-dev packageName

—save

安装的包是核心依赖项。

–保存开发

安装的包不是核心依赖项,而是开发依赖项。

仅在开发时使用

——save-dev表示在生产环境中省略,只在开发环境中使用(更小,可能更快)。

当你使用参数"——save"时,你的依赖项将在package.json的#1中。当你使用参数"——save-dev"时,你的依赖项将在package.json的#2中。

# 1。"dependencies":这些包是生产应用程序所需要的。

# 2。“devDependencies”:这些包只在开发和测试时需要

为了补充Andreas的回答,你可以使用以下命令只安装依赖项:

npm install --production