胖鸭 2012-02-13 21:25
浏览 1190
已采纳

如何防止为 Node.js (package.json)安装"devDependencies"NPM 模块?

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?

转载于:https://stackoverflow.com/questions/9268259/how-do-you-prevent-install-of-devdependencies-npm-modules-for-node-js-package

  • 写回答

13条回答 默认 最新

  • MAO-EYE 2012-02-14 11:33
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(12条)

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料