npm install multiple package names

Command LineNpmGulpBrowser Sync

Command Line Problem Overview


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:bufferutil@1.1.0 bufferutil@1.1.0 install: `node-gyp rebuild`
npm WARN install:bufferutil@1.1.0 Exit status 1

> utf-8-validate@1.1.0 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:utf-8-validate@1.1.0 utf-8-validate@1.1.0 install: `node-gyp rebuild`
npm WARN install:utf-8-validate@1.1.0 Exit status 1
lukasradek@1.0.0 C:\1HLAVNI\Lukas\Webdesign\lukasradek
+-- gulp-add-src@0.2.0
| +-- event-stream@3.1.7
| | `-- [email protected]
| +-- [email protected]
| | `-- readable-stream@1.0.34
| `-- [email protected]
|   +-- [email protected]
|   `-- xtend@2.1.2
|     `-- [email protected]
`-- gulp-babel@6.1.2
  +-- babel-core@6.13.2
  | +-- babel-code-frame@6.11.0
  | | `-- [email protected]
  | +-- [email protected]
  | | +-- [email protected]
  | | | `-- repeating@1.1.3
  | | `-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | | +-- [email protected]
  | | +-- [email protected]
  | | +-- [email protected]
  | | +-- [email protected]
  | | `-- source-map-support@0.2.10
  | |   `-- [email protected]
  | +-- [email protected]
  | | `-- regenerator-runtime@0.9.5
  | +-- babel-template@6.9.0
  | | `-- [email protected]
  | +-- [email protected]
  | | +-- [email protected]
  | | +-- [email protected]
  | | | `-- loose-envify@1.2.0
  | | |   `-- [email protected]
  | | `-- lodash@4.14.1
  | +-- babel-types@6.13.0
  | | +-- lodash@4.14.1
  | | `-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | `-- slash@1.0.0
  `-- object-assign@4.1.0

npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.14
npm WARN lukasradek@1.0.0 No repository field.

Command Line Solutions


Solution 1 - Command Line

Save as dependencies:

npm i package1 package2

Save as dev-dependencies:

npm i -D package1 package2

npm i --save-dev package1 package2

Solution 2 - Command Line

> 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.

Solution 3 - Command Line

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.

Solution 4 - Command Line

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLukáš ŘádekView Question on Stackoverflow
Solution 1 - Command LineCarlos PerezView Answer on Stackoverflow
Solution 2 - Command LineHiDeoView Answer on Stackoverflow
Solution 3 - Command Lineuser9019365View Answer on Stackoverflow
Solution 4 - Command Lineaggregate1166877View Answer on Stackoverflow