VSTS轰炸NPM安装吗?

时间:2018-07-28 20:12:14

标签: angular npm azure-devops angular-cli

我有一个类似的VSTS批处理脚本:

cd (my UI dir)
echo npm install...
npm install
echo ng build --output-path %1\ui
ng build --output-path %1\ui
echo npm run ng build --output-path %1\ui
npm run ng build --output-path %1\ui
echo All done.

但是,令人费解的是,我似乎无法超越npm安装线。我的输出类似于:

2018-07-28T20:03:12.8414522Z ##[section]Starting: Run script BuildUi.bat
2018-07-28T20:03:12.8705378Z ==============================================================================
2018-07-28T20:03:12.8705624Z Task         : Batch Script
2018-07-28T20:03:12.8705839Z Description  : Run a windows cmd or bat script and optionally allow it to change the environment
2018-07-28T20:03:12.8706039Z Version      : 1.1.3
2018-07-28T20:03:12.8706207Z Author       : Microsoft Corporation
2018-07-28T20:03:12.8706405Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613733)
2018-07-28T20:03:12.8706654Z ==============================================================================
2018-07-28T20:03:12.8810206Z ##[command]D:\Projects\vsts-agent-win-x64-2.136.1\_work\1\s\BuildUi.bat D:\Projects\vsts-agent-win-x64-2.136.1\_work\1\a
2018-07-28T20:03:12.9157783Z 
2018-07-28T20:03:12.9158312Z D:\Projects\vsts-agent-win-x64-2.136.1\_work\1\s>cd myuiproject 
2018-07-28T20:03:12.9158475Z 
2018-07-28T20:03:12.9158666Z D:\Projects\vsts-agent-win-x64-2.136.1\_work\1\s\myuiproject>echo npm install... 
2018-07-28T20:03:12.9158918Z npm install...
2018-07-28T20:03:12.9159011Z 
2018-07-28T20:03:12.9159198Z D:\Projects\vsts-agent-win-x64-2.136.1\_work\1\s\myuiproject>npm install 
2018-07-28T20:03:38.6909464Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.2 (node_modules\@angular-devkit\core\node_modules\chokidar\node_modules\fsevents):
2018-07-28T20:03:38.6911145Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
2018-07-28T20:03:38.6912865Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.2 (node_modules\watchpack\node_modules\chokidar\node_modules\fsevents):
2018-07-28T20:03:38.6913360Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
2018-07-28T20:03:38.6914230Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.2 (node_modules\webpack-dev-server\node_modules\chokidar\node_modules\fsevents):
2018-07-28T20:03:38.6914844Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
2018-07-28T20:03:38.6915700Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
2018-07-28T20:03:38.6916232Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
2018-07-28T20:03:38.6917088Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.2 (node_modules\karma\node_modules\chokidar\node_modules\fsevents):
2018-07-28T20:03:38.6917734Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
2018-07-28T20:03:38.6919280Z npm WARN @angular/flex-layout@2.0.0-beta.12 requires a peer of @angular/core@~5.1.0 but none was installed.
2018-07-28T20:03:38.6919744Z npm WARN @angular/flex-layout@2.0.0-beta.12 requires a peer of @angular/common@~5.1.0 but none was installed.
2018-07-28T20:03:38.7159772Z ##[section]Finishing: Run script BuildUi.bat

这里有些警告我很容易忽略,但是批处理文件被认为是“已成功执行”,并且继续运行...没有我构建的UI项目(这很重要!)

有人可以向我解释这是怎么回事,以及如何从VSTS CI任务构建UI项目吗?我不知道这是VSTS,NPM还是角度CLI的问题,但是这个愚蠢的简单事情完全阻止了我设置CI构建。

解决方案

正如@CeceDong所建议的,我使用了错误的任务来实现这一目标。

  • 首先,我需要确保已安装正确版本的Node.js(对于Angular 6 CLI,版本为v8.9 +)。方便地,有一项任务可确保安装正确版本的Node。
  • 第二,我需要在角度项目目录中调用npm命令来运行npm install
  • 最后,我需要在我的角度项目目录中运行命令行任务:npm run ng build。它不会接受常规的ng build命令。一旦完成这些步骤,它就会按预期运行。

1 个答案:

答案 0 :(得分:2)

您可以使用npm任务来运行npm installnpm custom来查看是否可以成功构建:

enter image description here