简体   繁体   English

VSTS轰炸NPM安装?

[英]VSTS Bombing out NPM Install?

I have a VSTS Batch Script like so: 我有一个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.

yet, inexplicably, I cannot seem to get past the npm install line. 然而,莫名其妙的是,我似乎无法超越npm安装线。 My output resembles this: 我的输出类似于:

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

There's some warnings here which I'm comfortable ignoring, but the batch file is considered "successfully executed" and continues on... sans my built UI project (which is kinda an important piece!) 这里有些警告我很容易忽略,但是批处理文件被视为“已成功执行”,并且继续进行下去...没有我构建的UI项目(这很重要!)

Can someone explain to me what is going on here, and how I can build my UI project from a VSTS CI task? 有人可以向我解释这是怎么回事,以及如何从VSTS CI任务构建UI项目吗? I don't know if this is a problem with VSTS, NPM, or angular CLI, but this stupid simple thing is completely blocking me from setting up my CI build. 我不知道这是VSTS,NPM还是angular CLI的问题,但是这个愚蠢的简单事情完全阻止了我设置CI构建。

SOLUTION

As @CeceDong suggested, I was using the wrong task to make this happen. 正如@CeceDong所建议的,我使用了错误的任务来实现这一目标。

  • First, I needed to ensure I had the proper version of Node.js installed (for Angular 6 CLI, that's v8.9+). 首先,我需要确保已安装正确版本的Node.js(对于Angular 6 CLI,则为v8.9 +)。 Conveniently, there is a task to ensure that the proper version of Node is installed. 方便地,有一项任务可确保安装正确版本的Node。
  • Second, I needed to invoke the npm commmand in the angular project directory to run npm install . 其次,我需要在angular项目目录中调用npm commmand来运行npm install
  • Finally, I needed to run a Command Line task: npm run ng build in my angular project directory. 最后,我需要运行一个命令行任务:在我的角度项目目录中npm run ng build It wouldn't accept a regular ng build command. 它不会接受常规的ng build命令。 Once I got these steps worked out, it operated as I expected it to. 一旦完成这些步骤,它就会按预期运行。

You could use npm task to run npm install or npm custom to see whether you can have a successful build: 您可以使用npm任务运行npm installnpm custom来查看是否可以成功构建:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM