[英]Angular build error on Azure DevOps with powershell script
I prepared a powershell script in azure devops build pipeline to create an artifact, but when I start build queue, I get an error which is below. 我在azure devops构建管道中准备了一个powershell脚本来创建工件,但是当我开始构建队列时,出现以下错误。
The build command requires to be run in an Angular project, but a project definition could not be found.
build命令需要在Angular项目中运行,但是找不到项目定义。
Can someone help me please. 有人能帮助我吗。
Powershell script: Powershell脚本:
npm install
npm install -g typescript
npm install -g @angular/cli
ng build --configuration=production
This is all the result of powershell script: 这是powershell脚本的全部结果:
##[section]Starting: PowerShell Script
==============================================================================
Task : PowerShell
Description : Run a PowerShell script on Windows, macOS, or Linux.
Version : 2.148.0
Author : Microsoft Corporation
Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613736)
==============================================================================
Generating script.
========================== Starting Command Output ===========================
##[command]"C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'd:\a\_temp\90129c3e-4840-41d7-895c-2f9c8f6e5968.ps1'"
npm WARN saveError ENOENT: no such file or directory, open 'D:\a\1\s\package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open 'D:\a\1\s\package.json'
npm WARN s No description
npm WARN s No repository field.
npm WARN s No README data
npm WARN s No license field.
up to date in 5.231s
found 0 vulnerabilities
C:\npm\prefix\tsc -> C:\npm\prefix\node_modules\typescript\bin\tsc
C:\npm\prefix\tsserver -> C:\npm\prefix\node_modules\typescript\bin\tsserver
+ typescript@3.4.5
updated 1 package in 2.063s
C:\npm\prefix\ng -> C:\npm\prefix\node_modules\@angular\cli\bin\ng
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\@angular\cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ @angular/cli@7.3.9
added 295 packages from 180 contributors in 88.373s
The build command requires to be run in an Angular project, but a project definition could not be found.
##[error]PowerShell exited with code '1'.
##[section]Finishing: PowerShell Script
As the error said, you try to run ng build
not in the project folder. 如错误所述,您尝试不在项目文件夹中运行
ng build
。
You need to run cd path/to/project-folder
before. 您需要先运行
cd path/to/project-folder
。
Another option, in the Azure DevOps PowerShell task there is a option to specify "Working Directory" so enter there the project path. 另一个选项是,在Azure DevOps PowerShell任务中,有一个选项可以指定“工作目录”,因此请在其中输入项目路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.