在Azure DevOps管道中NG生成失败:错误:找不到模块'../internal/operators/audit'

时间:2019-05-20 11:13:50

标签: angular azure-devops

我正在尝试为Angular项目配置Azure CI / CD

下面是azure管道的屏幕截图: enter image description here

Package.json

enter image description here

Build Project引发以下错误:

2019-05-20T09:19:18.0252202Z > ng build
2019-05-20T09:19:18.0252697Z     ^
2019-05-20T09:19:18.0253091Z 
2019-05-20T09:19:18.0253456Z 
2019-05-20T09:19:18.0254242Z Error: Cannot find module '../internal/operators/audit'
2019-05-20T09:19:18.0254971Z     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
2019-05-20T09:19:18.0255650Z     at Function.Module._load (internal/modules/cjs/loader.js:508:25)
2019-05-20T09:19:18.0256280Z     at Module.require (internal/modules/cjs/loader.js:637:17)
2019-05-20T09:19:18.0257011Z     at require (internal/modules/cjs/helpers.js:22:18)
2019-05-20T09:19:18.0257814Z     at Object.<anonymous> (D:\a\1\s\IoTConnectAI\node_modules\@angular-devkit\schematics\node_modules\rxjs\operators\index.js:3:15)
2019-05-20T09:19:18.0258514Z     at Module._compile (internal/modules/cjs/loader.js:701:30)
2019-05-20T09:19:18.0259140Z     at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
2019-05-20T09:19:18.0259776Z     at Module.load (internal/modules/cjs/loader.js:600:32)
2019-05-20T09:19:18.0260390Z     at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
2019-05-20T09:19:18.0264689Z     at Function.Module._load (internal/modules/cjs/loader.js:531:3)
2019-05-20T09:19:18.0265336Z npm ERR! code ELIFECYCLE
2019-05-20T09:19:18.0265959Z npm ERR! errno 1
2019-05-20T09:19:18.0266569Z npm ERR! sconnectai@0.0.0 build: `ng build`
2019-05-20T09:19:18.0267438Z npm ERR! Exit status 1
2019-05-20T09:19:18.0268063Z npm ERR! 
2019-05-20T09:19:18.0268686Z npm ERR! Failed at the sconnectai@0.0.0 build script.
2019-05-20T09:19:18.0270422Z npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-05-20T09:19:18.0271137Z 

尝试了 ng build --prod

enter image description here

请帮助我解决此问题

2 个答案:

答案 0 :(得分:0)

代替运行构建,将其更改为

ng build --prod

https://slides.com/sajeetharansinnathurai/angular-continuous-integration#/13

答案 1 :(得分:0)

尝试使用npm命令构建项目的根本原因 npm运行构建

ng构建无法正常工作,并且由于尝试使用npm工具而给出了此类命令的错误。

在Azure DevOps管道中添加命令行任务并使用ng build来构建项目 enter image description here

工作正常,并成功构建了项目