npm install multiple package names
Asked Answered
P

5

77

What does it do when I run this command:

npm install --save-dev package1 package2

It is definitely not installing multiple packages, but it looks to be essential. (For example https://www.browsersync.io/docs/gulp)

For me it throws following ERRs:

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.
Pod answered 7/8, 2016 at 19:8 Comment(3)
So you state that "It is definitely not installing multiple packages" - what does it do in your case? What's the console output after running that command?Zhang
It gives a long list of error, that it does not produce, while installing packages individually. See updated post.Hailstorm
Do you mean errors? Those packages need Python, install Python with proper version and re-install, you won't see those errors again.City
H
12

It is definitely not installing multiple packages

Why? You're installing package1 and package2 and marking them as devDependencies with --save-dev.

As stated in the documentation, you may combine multiple arguments, and even multiple types of arguments. In your case, you're combining 2 package names published on the registry.

Highland answered 7/8, 2016 at 19:15 Comment(1)
Stangely for me it throws multiple errors not even revolving around the installed packages. If I try to install it one by one, everything is OK. See my updated post.Hailstorm
G
149

Save as dependencies:

npm i package1 package2

Save as dev-dependencies:

npm i -D package1 package2

npm i --save-dev package1 package2
Gilmour answered 30/7, 2017 at 15:16 Comment(0)
H
12

It is definitely not installing multiple packages

Why? You're installing package1 and package2 and marking them as devDependencies with --save-dev.

As stated in the documentation, you may combine multiple arguments, and even multiple types of arguments. In your case, you're combining 2 package names published on the registry.

Highland answered 7/8, 2016 at 19:15 Comment(1)
Stangely for me it throws multiple errors not even revolving around the installed packages. If I try to install it one by one, everything is OK. See my updated post.Hailstorm
P
3

npm install --save module1 module2

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

The above command will install the latest versions of morgan, chalk, errorhandler, lusca, dotenv, path and mongoose.

Philology answered 30/10, 2018 at 6:31 Comment(0)
R
1

The other answers here do not appear to answer the question. Specifically, doing an npm install --save-dev p1 p2 p3 does not cause p2 and p3 to be stored in my package.json file.

The following line installs all packages + saves it in dev dependencies for me:

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

I'm on Windows and use Cygwin, but this works on *nix systems, too.

Somewhat unrelated but very important if using Cygwin: if you do use Cygwin, you need to add noacl to your mount options, or it will mess up your module permissions and cause Windows to freak out.

Ruthven answered 6/11, 2021 at 0:18 Comment(0)
G
0

What I do is

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

Here what I did was install all dependencies with npm i with space to separate packages and when I want to download dev dependencies I use && and npm i -D with space to install multiple dev dependencies packages.

Generate Rule

npm i package1 package2 .... && npm i -D devDependenciesPackage1 devDependenciesPackage2 ...

Indication
&& to separate dependencies with Dev Dependecies

... to indicate that you are add more package before && symbol

Gunshot answered 31/3 at 8:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.