如何使用 npm 仅安装 "devDependencies"
How to install only "devDependencies" using npm
我正在尝试仅安装 package.json 文件中列出的 "devDependencies"。但是以下命令中的 none 按我的预期工作。以下所有命令也会安装我不想要的生产依赖项。
npm install --dev
npm install --only=dev
npm install --only-dev
我想不出更多的方法来告诉 npm 单独安装 devDependencies。 :(
With the --production
flag (or when the NODE_ENV
environment variable is set to production), npm will not install modules listed in devDependencies
.
The --only={prod[uction]|dev[elopment]}
argument will cause either only devDependencies or only non-devDependencies to be installed regardless of the NODE_ENV.
您尝试过以下方法吗?
npm install --only=dev
npm install thePackageName --save-dev
这对我来说很好。
npm i -D
一个可选的短版本。
运行 npm install
,它将安装 devDependencies` 或 dependencies.[=25 下的所有依赖项=]
用于在 package.json 中安装和保存包作为开发依赖项,
npm install package_name --save-dev
或传递选项 -D
用于安装 devDependencies 下的所有包,
npm install --only=dev
为了在 package.json 中安装和保存包作为产品或仅依赖项,
npm install package_name --save-prod
或传递选项 -P
或 npm install package_name
用于安装 dependencies 或 Prod dependencies 下的所有包,
设置环境变量 NODE_ENV=production
或使用命令 NODE_ENV=production npm install
或 npm install --only=prod
传递它
您可以像 npm i
一样在 npm 命令中使用 install
而不是像 npm install
那样使用 i
,而不是 install.
不再支持 --only=dev 选项。执行开发依赖安装 运行 npm install --production=false
从 npm 版本 7.10.0 开始,您可以省略某些类型的依赖项,但是您不能再省略“the”依赖项(生产)。这就是为什么这个问题没有解决方案了。
我正在尝试仅安装 package.json 文件中列出的 "devDependencies"。但是以下命令中的 none 按我的预期工作。以下所有命令也会安装我不想要的生产依赖项。
npm install --dev
npm install --only=dev
npm install --only-dev
我想不出更多的方法来告诉 npm 单独安装 devDependencies。 :(
With the
--production
flag (or when theNODE_ENV
environment variable is set to production), npm will not install modules listed indevDependencies
.The
--only={prod[uction]|dev[elopment]}
argument will cause either only devDependencies or only non-devDependencies to be installed regardless of the NODE_ENV.
您尝试过以下方法吗?
npm install --only=dev
npm install thePackageName --save-dev
这对我来说很好。
npm i -D
一个可选的短版本。
运行 npm install
,它将安装 devDependencies` 或 dependencies.[=25 下的所有依赖项=]
用于在 package.json 中安装和保存包作为开发依赖项,
npm install package_name --save-dev
或传递选项 -D
用于安装 devDependencies 下的所有包,
npm install --only=dev
为了在 package.json 中安装和保存包作为产品或仅依赖项,
npm install package_name --save-prod
或传递选项 -P
或 npm install package_name
用于安装 dependencies 或 Prod dependencies 下的所有包,
设置环境变量 NODE_ENV=production
或使用命令 NODE_ENV=production npm install
或 npm install --only=prod
您可以像 npm i
一样在 npm 命令中使用 install
而不是像 npm install
那样使用 i
,而不是 install.
不再支持 --only=dev 选项。执行开发依赖安装 运行 npm install --production=false
从 npm 版本 7.10.0 开始,您可以省略某些类型的依赖项,但是您不能再省略“the”依赖项(生产)。这就是为什么这个问题没有解决方案了。