Azure NodeJS Azure Devops部署失败,但Visual Studio部署运行良好



我们正在尝试将NodeJS应用程序部署到Azure应用程序服务(Linux(,如果我们从Visual Studio部署它,一切都很好,网站呈现完美。现在,我们创建了一个基本的构建/发布管道,并将zip文件(从构建创建(部署到Azure上的应用程序服务,然后如果我们试图渲染该网站,它会引发应用程序错误(以下是错误日志(:

> 2020-04-15T20:27:47.222887443Z > externalservicestatus@0.0.0 start /home/site/wwwroot
2020-04-15T20:27:47.222895143Z > node ./bin/www
2020-04-15T20:27:47.222899943Z
2020-04-15T20:27:47.371119383Z internal/modules/cjs/loader.js:797
2020-04-15T20:27:47.371195483Z     throw err;
2020-04-15T20:27:47.371942583Z     ^
2020-04-15T20:27:47.371974683Z
2020-04-15T20:27:47.372042983Z ***Error: Cannot find module '/home/site/wwwroot/bin/www'
2020-04-15T20:27:47.372063083Z     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
2020-04-15T20:27:47.372103483Z     at Function.Module._load (internal/modules/cjs/loader.js:687:27)
2020-04-15T20:27:47.372136083Z     at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10)
2020-04-15T20:27:47.372176983Z     at internal/main/run_main_module.js:17:11 {
2020-04-15T20:27:47.372206183Z   code: 'MODULE_NOT_FOUND',***
2020-04-15T20:27:47.372292683Z   requireStack: []
2020-04-15T20:27:47.372316483Z }
2020-04-15T20:27:47.402670091Z npm ERR! code ELIFECYCLE
2020-04-15T20:27:47.409661993Z npm ERR! errno 1
2020-04-15T20:27:47.411500494Z npm ERR! externalservicestatus@0.0.0 start: `node ./bin/www`
2020-04-15T20:27:47.412151894Z npm ERR! Exit status 1
2020-04-15T20:27:47.412616894Z npm ERR!
2020-04-15T20:27:47.419115996Z npm ERR! Failed at the externalservicestatus@0.0.0 start script.
2020-04-15T20:27:47.419849596Z npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-04-15T20:27:47.432179799Z
2020-04-15T20:27:47.432704699Z npm ERR! A complete log of this run can be found in:
2020-04-15T20:27:47.433290000Z npm ERR!     /root/.npm/_logs/2020-04-15T20_27_47_420Z-debug.log
2020-04-15 20:27:48.453 ERROR - Container testexternalapp2_0_6702db49 for site testexternalapp2 has exited, failing site start
2020-04-15 20:27:48.464 ERROR - Container testexternalapp2_0_6702db49 didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging.

我发现,无论何时从Visual Studio"./bin/www"部署,都会创建并部署在应用程序服务上,但无论何时从Azure DevOps Release管道部署,"./bin/wwww"都会丢失且不可用。有什么帮助吗?

当从VisualStudio:部署时,这就是我从日志流中看到的内容

> /appsvctmp/volatile/logs/runtime/afbd672b48147e81a539c200a40b91607386719df21a7e51f842abbcd70c89db.log 
2020-04-15T17:47:12.057871083Z: [INFO]  echo "Done."
2020-04-15T17:47:12.057884183Z: [INFO]  PATH="$PATH:/home/site/wwwroot" npm start
2020-04-15T17:47:13.285047383Z: [INFO]  Found tar.gz based node_modules.
2020-04-15T17:47:13.295572890Z: [INFO]  Removing existing modules directory from root...
2020-04-15T17:47:13.307481412Z: [INFO]  Extracting modules...
2020-04-15T17:47:17.392564316Z: [INFO]  Done.
2020-04-15T17:47:22.666823807Z: [INFO]  
2020-04-15T17:47:22.666850507Z: [INFO]  > externalservicestatus@0.0.0 start /home/site/wwwroot
2020-04-15T17:47:22.666855308Z: [INFO]  > node ./bin/www
2020-04-15T17:47:22.666858408Z: [INFO]  

当从Azure DevOps部署时,这就是我从日志中看到的:

2020-04-15T21:17:50.664112070Z npm ERR! errno 1
2020-04-15T21:17:50.664156869Z npm ERR! externalservicestatus@0.0.0 start: `node ./bin/www`
2020-04-15T21:17:50.664174469Z npm ERR! Exit status 1
2020-04-15T21:17:50.664206269Z npm ERR! 
2020-04-15T21:17:50.664220669Z npm ERR! Failed at the externalservicestatus@0.0.0 start script.
2020-04-15T21:17:50.664251169Z npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-04-15T21:17:50.713658687Z 
2020-04-15T21:17:50.713714987Z npm ERR! A complete log of this run can be found in:
2020-04-15T21:17:50.713837887Z npm ERR!     /root/.npm/_logs/2020-04-15T21_17_50_672Z-debug.log

请下载您的工件并查看里面的内容。

由于管道中的路径配置错误,发布文件时可能会出现问题。如果您在本例中缺少预期的文件/文件夹./bin/www,那么您可能在管道中出现了一些错误,Azure上的一切都很好。

在这种情况下,我还建议添加bash: ls your-publish-directory步骤来检查内容。

最新更新