npm install:有没有办法忽略package.json中的特定依赖项 [英] npm install: Is there a way to ignore a particular dependency in package.json

查看:1309
本文介绍了npm install:有没有办法忽略package.json中的特定依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试为包含本地依赖项的node.js项目创建一个docker容器.这似乎引起了docker问题,因此,作为一种解决方法,我试图仅复制本地依赖项文件夹,而忽略package.json文件中的依赖项条目.有没有一种方法可以指定我想忽略的依赖项,并运行npm install并跳过这些实体?

I am currently trying to create a docker container for a node.js project that contains a local dependency. This seems to cause an issue with docker so as a workaround I am trying to just copy the local dependency folders and just ignore their dependency entries in the package.json file. Is there a way to specify dependencies I would like to ignore and have npm install run and skip those enties?

推荐答案

可以使用 devDependencies

您仅需要开发的npm模块,例如:单元测试,Coffeescript到Javascript的翻译,缩小等,就可以将所需的模块设置为devDependency.

The npm modules which you require only to develop, e.g.: unit tests, Coffeescript to Javascript transpilation, minification etc,make the required module a devDependency.

要跳过devDepenencies的安装,请将--production标志传递给npm install,并且将--production标志(或NODE_ENV环境变量设置为production),npm不会安装devDependencies中列出的模块."/p>

To skip Installation of devDepenencies pass --production flag to npm install,with the --production flag(or NODE_ENV environment variable set to production) npm will not install modules listed in devDependencies."

npm install --production

要使任何模块成为devDependencies的一部分,请在安装时传递--dev.

To make any module to be part of devDependencies pass --dev while installing.

npm install packagename --save-dev

这篇关于npm install:有没有办法忽略package.json中的特定依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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