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

ⅰ亾dé卋堺 提交于 2020-08-14 08:18:48

问题:

I have this in my package.json file (shortened version): 我的package.json文件(简化版)中有这个:

{
  "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. 我在Mac 10.6.8上使用NPM 1.1.1版本。

When I run the following command from the project root, it installs both the dependencies and devDependencies : 当我从项目根目录运行以下命令时,它将安装dependencies devDependencies

npm install

I was under the impression that this command installed the devDependencies : 我对这个命令的印象是安装了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 ? 如何使npm install仅安装dependencies (因此生产环境仅获取那些模块),而像npm install --dev那样同时安装dependenciesdevDependencies


解决方案:

参考一: https://stackoom.com/question/ct63/如何防止为Node-js-package-json-安装-devDependencies-NPM模块
参考二: https://oldbug.net/q/ct63/How-do-you-prevent-install-of-devDependencies-NPM-modules-for-Node-js-package-json
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!