如何在特定目录中安装npm软件包

时间:2016-07-07 11:37:00

标签: node.js npm

要在当前目录中安装package.json的软件包,您需要运行npm install命令。

是否可以在特定文件夹中安装package.json的软件包,而无需转到该文件夹​​?“

已经找到了凉亭和gulp任务的解决方案:

bower install --config.cwd=<directory>
gulp build --cwd <directory>

但缺少npm

的类似功能

当我运行命令时:npm install --prefix C:\Users\ng\Projects\Lottery\src\SPA 我看到一个错误:

npm ERR! addLocal Could not install C:\Users\ng\Projects
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--prefix" "C:\\Users\\ng\\Projects\\Lottery\\src\\SPA"
npm ERR! node v6.2.1
npm ERR! npm  v3.9.3
npm ERR! code EISDIR
npm ERR! errno -4068
npm ERR! syscall read

npm ERR! eisdir EISDIR: illegal operation on a directory, read
npm ERR! eisdir This is most likely not a problem with npm itself
npm ERR! eisdir and is related to npm not being able to find a package.json in
npm ERR! eisdir a package you are trying to install.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\ng\Projects\npm-debug.log

来自documentation

  

前缀配置默认为安装节点的位置。上   大多数系统,这是/ usr / local。在Windows上,这是确切的   node.exe二进制文件的位置

1 个答案:

答案 0 :(得分:1)

这应该是解决方案:How to npm install to a specified directory?

基本上,您使用前缀选项和全局选项: <marquee behavior="scroll" height="50px" scrollamount="1" direction="up" onmouseover="this.stop();" onmouseout="this.start();"> <!---*********************** Php Code Start ***************************---> <?php //********** Php code goes here *********** ?> <!---******************** Php Code End ********************************---> </marquee>

您还可以查看documentation