您如何防止安装"devDependencies"?适用于Node.js(package.json)的NPM模块吗? [英] How do you prevent install of "devDependencies" NPM modules for Node.js (package.json)?

查看:71
本文介绍了您如何防止安装"devDependencies"?适用于Node.js(package.json)的NPM模块吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的package.json文件中有此文件(简化版):

{
  "name": "a-module",
  "version": "0.0.1",
  "dependencies": {
    "coffee-script":      ">= 1.1.3"
  },
  "devDependencies": {
    "stylus":             ">= 0.17.0"
  }
}

我正在Mac 10.6.8上使用NPM 1.1.1.

当我从项目根目录运行以下命令时,它将同时安装dependencies devDependencies:

npm install

给我的印象是该命令安装了devDependencies:

npm install --dev

我该如何做,以便npm install仅安装dependencies(因此生产环境仅获取那些模块),而类似npm install --dev的东西同时安装dependenciesdevDependencies?

解决方案

在开发环境中(默认设置)在程序包目录中运行时,npm install命令将与其他dependencies一起安装devDependencies. /p>

使用npm install --only=prod(或--only=production)仅安装 dependencies,而不安装devDependencies,,而不考虑NODE_ENV环境变量的值.

来源: npm文档

注意:在npm(2015-08-13)的v3.3.0之前,该选项名为--production,即npm install --production.

I have this in my package.json file (shortened version):

{
  "name": "a-module",
  "version": "0.0.1",
  "dependencies": {
    "coffee-script":      ">= 1.1.3"
  },
  "devDependencies": {
    "stylus":             ">= 0.17.0"
  }
}

I am using NPM version 1.1.1 on Mac 10.6.8.

When I run the following command from the project root, it installs both the dependencies and devDependencies:

npm install

I was under the impression that this command installed the devDependencies:

npm install --dev

How do I make it so npm install only installs dependencies (so production environment only gets those modules), while something like npm install --dev installs both dependencies and devDependencies?

解决方案

The npm install command will install the devDependencies along other dependencies when run inside a package directory, in a development environment (the default).

Use npm install --only=prod (or --only=production) to install only dependencies, and not devDependencies,regardless of the value of the NODE_ENV environment variable.

Source: npm docs

Note: Before v3.3.0 of npm (2015-08-13), the option was called --production, i.e. npm install --production.

这篇关于您如何防止安装"devDependencies"?适用于Node.js(package.json)的NPM模块吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆