npm 安装多个包名称

问题描述 投票:0回答:5

当我运行此命令时它会做什么:

npm install --save-dev package1 package2

它绝对不是安装多个软件包,但它看起来是必不可少的。 (例如https://www.browsersync.io/docs/gulp

对我来说,它会抛出以下错误:

C:\1HLAVNI\Lukas\Webdesign\lukasradek>npm install --save-dev gulp-babel gulp-add-src

> [email protected] install C:\1HLAVNI\Lukas\Webdesign\lukasradek\node_modules\bufferutil
> node-gyp rebuild


C:\1HLAVNI\Lukas\Webdesign\lukasradek\node_modules\bufferutil>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:401:14)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:356:11
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:123:15)
gyp ERR! System Windows_NT 10.0.10586
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\1HLAVNI\Lukas\Webdesign\lukasradek\node_modules\bufferutil
gyp ERR! node -v v6.3.1
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
npm WARN install:[email protected] [email protected] install: `node-gyp rebuild`
npm WARN install:[email protected] Exit status 1

> [email protected] install C:\1HLAVNI\Lukas\Webdesign\lukasradek\node_modules\utf-8-validate
> node-gyp rebuild


C:\1HLAVNI\Lukas\Webdesign\lukasradek\node_modules\utf-8-validate>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:401:14)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:356:11
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:123:15)
gyp ERR! System Windows_NT 10.0.10586
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\1HLAVNI\Lukas\Webdesign\lukasradek\node_modules\utf-8-validate
gyp ERR! node -v v6.3.1
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
npm WARN install:[email protected] [email protected] install: `node-gyp rebuild`
npm WARN install:[email protected] Exit status 1
[email protected] C:\1HLAVNI\Lukas\Webdesign\lukasradek
+-- [email protected]
| +-- [email protected]
| | `-- [email protected]
| +-- [email protected]
| | `-- [email protected]
| `-- [email protected]
|   +-- [email protected]
|   `-- [email protected]
|     `-- [email protected]
`-- [email protected]
  +-- [email protected]
  | +-- [email protected]
  | | `-- [email protected]
  | +-- [email protected]
  | | +-- [email protected]
  | | | `-- [email protected]
  | | `-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | | +-- [email protected]
  | | +-- [email protected]
  | | +-- [email protected]
  | | +-- [email protected]
  | | `-- [email protected]
  | |   `-- [email protected]
  | +-- [email protected]
  | | `-- [email protected]
  | +-- [email protected]
  | | `-- [email protected]
  | +-- [email protected]
  | | +-- [email protected]
  | | +-- [email protected]
  | | | `-- [email protected]
  | | |   `-- [email protected]
  | | `-- [email protected]
  | +-- [email protected]
  | | +-- [email protected]
  | | `-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | `-- [email protected]
  `-- [email protected]

npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]
npm WARN [email protected] No repository field.

command-line npm gulp browser-sync
5个回答
147
投票

另存为依赖项:

npm i package1 package2

另存为开发依赖项:

npm i -D package1 package2

npm i --save-dev package1 package2

12
投票

绝对不是安装多个包

为什么?您正在安装 package1package2 并使用

devDependencies
将它们标记为
--save-dev

文档中所述,您可以组合多个参数,甚至多种类型的参数。在您的情况下,您将组合注册表上发布的 2 个包名称。


3
投票

npm install --save module1 module2

示例:

npm install --save morgan chalk errorhandler lusca dotenv path mongoose

上述命令将安装最新版本的 morgan、chalk、errorhandler、lusca、dotenv、path 和 mongoose。


1
投票

这里的其他答案似乎没有回答这个问题。具体来说,执行

npm install --save-dev p1 p2 p3
不会导致 p2 和 p3 存储在我的
package.json
文件中。

以下行安装所有软件包+将其保存在开发依赖项中:

for i in 'package1' 'package2'; do npm install --save-dev "$i"; done

我在 Windows 上使用 Cygwin,但这也适用于 *nix 系统。

如果使用 Cygwin,有些不相关但非常重要:如果您确实使用 Cygwin,您需要将

noacl
添加到您的挂载选项,否则它会弄乱您的模块权限并导致 Windows 崩溃。


0
投票

我所做的是

npm i @tanstack/react-query @tanstack/react-query-devtools && npm i -D @tanstack/eslint-plugin-query

这里我所做的是使用 npm i with space 将所有依赖项安装到 separate packages ,当 我想下载开发依赖项时,我使用 && 和 npm i -D with space 来安装多个开发依赖项包。

生成规则

npm i Package1 Package2 .... && npm i -D Package3 Package4

© www.soinside.com 2019 - 2024. All rights reserved.