Grunt.js: What does

I've just started using Grunt.js. It is pretty hard to set up and I am at the point of creating a package.json file.

Following this tutorial, it says there are 3 ways to create a package.json file.

The first is to do npm install grunt --save-dev

But what does --save-dev means? I tried looking but it ends in vain.


--save-dev: Package will appear in your devDependencies.

According to the npm install docs.

If someone is planning on downloading and using your module in their program, then they probably don't want or need to download and build the external test or documentation framework that you use.

In other words, when you run npm install , your project's devDependencies will be installed, but the devDependencies for any packages that your app depends on will not be installed; further, other apps having your app as a dependency need not install your devDependencies. Such modules should only be needed when developing the app (eg grunt, mocha etc).

According to the package.json docs.

Edit: Attempt at visualising what npm install does:

  • yourproject
  • dependency installed
  • dependecy installed
  • dependecy installed
  • devDependency NOT installed
  • devDependency NOT installed
  • devDependency installed
  • dependecy installed
  • devDependency NOT installed

  • There are (at least) two types of package dependencies you can indicate in your package.json files:

  • 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
    

  • 要添加到Andreas的答案中,因为我还没有评论,您可以使用以下命令只安装依赖关系: npm install --production

    链接地址: http://www.djcxy.com/p/27638.html

    上一篇: 安装更新版本的grunt

    下一篇: Grunt.js:什么