我目前正在使用npm install
来安装Angular2项目CI项目的所有软件包,但是这一步已经开始增加构建代理构建项目所需的时间。我想通过使用npm-cache
命令让我们的CI管道的构建运行时间缩短,但是我不断尝试通过构建代理运行命令。
我尝试过使用以下命令行步骤:
这导致错误File name doesn't indicate a full path to a executable file
。
我也试过添加了一个npm步骤:
结果如下:
2017-06-14T13:01:13.2274922Z [command] C:\ Program Files \ nodejs \ npm.cmd cache install
2017-06-14T13:01:19.8609829Z npm ERR!用法:npm cache添加tarball文件
2017-06-14T13:01:19.8630626Z npm ERR! npm cache add folder
2017-06-14T13:01:19.8630626Z npm ERR! npm cache add tarball url
2017-06-14T13:01:19.8640981Z npm ERR! npm cache add git url
2017-06-14T13:01:19.8651863Z npm ERR! npm cache add name @ version
2017-06-14T13:01:19.8661607Z npm ERR! npm cache ls path
2017-06-14T13:01:19.8672137Z npm ERR! npm cache clean pkg @ version
从团队服务中调用npm cache
的正确方法是什么?
答案 0 :(得分:4)
首先需要安装npm-cache软件包,然后通过命令行任务调用npm-cache命令。
C:\\Windows\\ServiceProfiles\\NetworkService\\AppData\\Roaming\\npm\\npm-cache
;参数:install
;工作文件夹:$(Build.SourcesDirectory)
)节点:之前的步骤使用通过 NetworkService 帐户作为服务运行的私有构建代理。您可以将C:\\Windows\\ServiceProfiles\\NetworkService\\AppData\\Roaming\\npm
添加到系统环境变量(需要重启机器)并直接调用npm-cache命令。
您还可以更改构建代理帐户以使用您的帐户(默认情况下C:\Users\[user name]\AppData\Roaming\npm
已添加到用户环境变量中),然后在安装 npm-后调用 npm-cache 命令使用 -g 参数缓存包
另一方面,主机代理不会缓存包,因此如果您使用的是托管代理,则无用。