npm 安装任务启动时间过长
npm install task taking too long to start
TFS 2017 构建定义上的 npm 安装任务启动时间太长 Ubuntu 构建代理:
2018-01-12T08:09:05.2269721Z [command]/usr/bin/npm install
2018-01-12T08:11:39.9810116Z npm WARN prefer global node-gyp@3.6.2 should be installed with -g
2018-01-12T08:11:43.0553293Z
2018-01-12T08:11:43.0578286Z > node-sass@4.7.2 install /home/johnny/myagent/_work/9/s/node_modules/node-sass
2018-01-12T08:11:43.0601546Z > node scripts/install.js
我想知道是什么导致 npm 需要 3 分钟才能显示 start.As,它从 08:09:05 开始,第一个回调是3 分钟后 08:11:39
如果此行为只发生在 NPM install
命令上,这是有道理的。 NPM install 只是在浪费时间,因为它需要 3-4 分钟才能确定软件包是否已经安装。
尝试 运行 你从控制台 npm 查看 TFS 上的性能是否正常。如果您所有的 NPM 任务都需要很长时间,一种可能与 nodejs 版本有关。
例如,您正在使用构建代理上安装的最新版本,例如 nodejs (8.x.0)。然后降级到最新的 LTS(长期支持)版本 (6.11.1) 可能会为您解决问题。详情请看这个blog.
另一种方法是使用 npm-cache,方法是 在构建机器上缓存以前安装的依赖项(如果您没有执行构建代理清理)。
It is useful for build processes that run [npm|bower|composer|jspm]
install every time as part of their build process. Since dependencies
don't change often, this often means slower build times. npm-cache
helps alleviate this problem by caching previously installed
dependencies on the build machine. npm-cache can be a drop-in
replacement for any build script that runs [npm|bower|composer|jspm]
install.
How it Works
When you run npm-cache install [npm|bower|jspm|composer], it first
looks for package.json, bower.json, or composer.json in the current
working directory depending on which dependency manager is requested.
It then calculates the MD5 hash of the configuration file and looks
for a filed named .tar.gz in the cache directory ($HOME/.package_cache
by default). If the file does not exist, npm-cache uses the system's
installed dependency manager to install the dependencies. Once the
dependencies are installed, npm-cache tars the newly downloaded
dependencies and stores them in the cache directory. The next time
npm-cache runs and sees the same config file, it will find the tarball
in the cache directory and untar the dependencies in the current
working directory.
TFS 2017 构建定义上的 npm 安装任务启动时间太长 Ubuntu 构建代理:
2018-01-12T08:09:05.2269721Z [command]/usr/bin/npm install
2018-01-12T08:11:39.9810116Z npm WARN prefer global node-gyp@3.6.2 should be installed with -g
2018-01-12T08:11:43.0553293Z
2018-01-12T08:11:43.0578286Z > node-sass@4.7.2 install /home/johnny/myagent/_work/9/s/node_modules/node-sass
2018-01-12T08:11:43.0601546Z > node scripts/install.js
我想知道是什么导致 npm 需要 3 分钟才能显示 start.As,它从 08:09:05 开始,第一个回调是3 分钟后 08:11:39
如果此行为只发生在 NPM install
命令上,这是有道理的。 NPM install 只是在浪费时间,因为它需要 3-4 分钟才能确定软件包是否已经安装。
尝试 运行 你从控制台 npm 查看 TFS 上的性能是否正常。如果您所有的 NPM 任务都需要很长时间,一种可能与 nodejs 版本有关。
例如,您正在使用构建代理上安装的最新版本,例如 nodejs (8.x.0)。然后降级到最新的 LTS(长期支持)版本 (6.11.1) 可能会为您解决问题。详情请看这个blog.
另一种方法是使用 npm-cache,方法是 在构建机器上缓存以前安装的依赖项(如果您没有执行构建代理清理)。
It is useful for build processes that run [npm|bower|composer|jspm] install every time as part of their build process. Since dependencies don't change often, this often means slower build times. npm-cache helps alleviate this problem by caching previously installed dependencies on the build machine. npm-cache can be a drop-in replacement for any build script that runs [npm|bower|composer|jspm] install.
How it Works
When you run npm-cache install [npm|bower|jspm|composer], it first looks for package.json, bower.json, or composer.json in the current working directory depending on which dependency manager is requested. It then calculates the MD5 hash of the configuration file and looks for a filed named .tar.gz in the cache directory ($HOME/.package_cache by default). If the file does not exist, npm-cache uses the system's installed dependency manager to install the dependencies. Once the dependencies are installed, npm-cache tars the newly downloaded dependencies and stores them in the cache directory. The next time npm-cache runs and sees the same config file, it will find the tarball in the cache directory and untar the dependencies in the current working directory.