在 Windows 机器上安装多包 npm 的正确语法是什么?

What is the proper syntax for multi-package npm installs on Windows machines?

这条语句

npm install --save @angular2-material/{core,button,card}

(取自here)产生

At line:1 char:44
+ npm install --save @angular2-material/{core,button,card}
+                                            ~
Missing argument in parameter list.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingArgument

在 Windows PowerShell 中产生

npm ERR! addLocal Could not install D:\VST\ngMaterial1\@angular2-material\{core,button,card}
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "D:\nodejs\node.exe" "D:\nodejs\node_modules\npm\bin\npm-cli.js" "install" "--save" "@angular2-material/{core,button,card}"
npm ERR! node v5.10.1
npm ERR! npm  v3.8.3
npm ERR! path D:\VST\ngMaterial1\@angular2-material\{core,button,card}
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open

npm ERR! enoent ENOENT: no such file or directory, open 'D:\VST\ngMaterial1\@angular2-material\{core,button,card}'
npm ERR! enoent ENOENT: no such file or directory, open 'D:\VST\ngMaterial1\@angular2-material\{core,button,card}'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! Please include the following file with any support request:
npm ERR!     D:\VST\ngMaterial1\npm-debug.log

在 Windows Console 中(以及在 PowerShell 中,当 --save 参数用引号引起来时) .

在 Windows 机器上安装多包 npm 的正确语法是什么?

正确的命令是npm i lodash hapi thinky when。您可以阅读更多 npm 技巧 here

以下命令:

npm install --save @angular2-material/{core,button,card}

由bash扩展为:

npm install --save @angular2-material/core @angular2-material/button @angular2-material/card

在 Windows 上,您可以使用 MingW Bash 实现完全相同的功能或手动扩展命令。

{package1, package2...} 技巧特定于 bash。这在 PowerShell 或 cmd 中不起作用。要在 Windows 上运行此功能,请打开一个新的 Git Bash(或等效)终端和 运行 命令,它应该可以运行。