Angular 为什么Azure Web App服务在其运行的docker容器中找不到ng?
正在尝试将基本web应用部署到Azure web应用服务,但似乎无法正常工作。我看到这个错误:Angular 为什么Azure Web App服务在其运行的docker容器中找不到ng?,angular,azure,npm,azure-web-app-service,github-actions,Angular,Azure,Npm,Azure Web App Service,Github Actions,正在尝试将基本web应用部署到Azure web应用服务,但似乎无法正常工作。我看到这个错误: 2019-12-27T23:37:42.634461405Z _____ 2019-12-27T23:37:42.634500106Z / _ \ __________ _________ ____ 2019-12-27T23:37:42.634511007Z / /_\ \___ / | \_ __ \
2019-12-27T23:37:42.634461405Z _____
2019-12-27T23:37:42.634500106Z / _ \ __________ _________ ____
2019-12-27T23:37:42.634511007Z / /_\ \___ / | \_ __ \_/ __ \
2019-12-27T23:37:42.634520107Z / | \/ /| | /| | \/\ ___/
2019-12-27T23:37:42.634528407Z \____|__ /_____ \____/ |__| \___ >
2019-12-27T23:37:42.634536708Z \/ \/ \/
2019-12-27T23:37:42.634544908Z A P P S E R V I C E O N L I N U X
2019-12-27T23:37:42.634553008Z
2019-12-27T23:37:42.634560609Z Documentation: http://aka.ms/webapp-linux
2019-12-27T23:37:42.634568609Z NodeJS quickstart: https://aka.ms/node-qs
2019-12-27T23:37:42.634576709Z NodeJS Version : v12.13.0
2019-12-27T23:37:42.634584609Z Note: Any data outside '/home' is not persisted
2019-12-27T23:37:42.634592610Z
2019-12-27T23:37:43.144384283Z Oryx Version: 0.2.20191105.2, Commit: 67e159d71419415435cb5d10c05a0f0758ee8809, ReleaseTagName: 20191105.2
2019-12-27T23:37:43.147834617Z Cound not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml'
2019-12-27T23:37:43.148467642Z Could not find operation ID in manifest. Generating an operation id...
2019-12-27T23:37:43.149091266Z Build Operation ID: c4f7694f-d5bc-4452-8bb2-c1e800f2d0e7
2019-12-27T23:37:44.402401478Z Environment Variables for Application Insight's Codeless Configuration exists..
2019-12-27T23:37:44.706186461Z Writing output script to '/opt/startup/startup.sh'
2019-12-27T23:37:45.084946652Z Running #!/bin/sh
2019-12-27T23:37:45.086758923Z
2019-12-27T23:37:45.086778423Z # Enter the source directory to make sure the script runs where the user expects
2019-12-27T23:37:45.088001471Z cd "/home/site/wwwroot"
2019-12-27T23:37:45.088021272Z
2019-12-27T23:37:45.088921606Z export NODE_PATH=$(npm root --quiet -g):$NODE_PATH
2019-12-27T23:37:45.088941007Z if [ -z "$PORT" ]; then
2019-12-27T23:37:45.089756039Z export PORT=8080
2019-12-27T23:37:45.089778440Z fi
2019-12-27T23:37:45.090585971Z
2019-12-27T23:37:45.090603272Z export NODE_OPTIONS='--require ./oryx-appinsightsloader.js ' $NODE_OPTIONS
2019-12-27T23:37:45.091407503Z npm start
2019-12-27T23:37:48.809993637Z
2019-12-27T23:37:48.810043739Z > angular-todo@0.0.0 start /home/site/wwwroot
2019-12-27T23:37:48.810054439Z > ng serve
2019-12-27T23:37:48.810063040Z
2019-12-27T23:37:48.866439626Z /home/site/wwwroot/node_modules/.bin/ng: 1: /home/site/wwwroot/node_modules/.bin/ng: ../@angular/cli/bin/ng: not found
2019-12-27T23:37:48.872441959Z npm ERR! code ELIFECYCLE
2019-12-27T23:37:48.874125524Z npm ERR! syscall spawn
2019-12-27T23:37:48.889093905Z npm ERR! file sh
2019-12-27T23:37:48.890656766Z npm ERR! errno ENOENT
2019-12-27T23:37:48.893052158Z npm ERR! angular-todo@0.0.0 start: `ng serve`
2019-12-27T23:37:48.894167002Z npm ERR! spawn ENOENT
2019-12-27T23:37:48.899168996Z npm ERR!
2019-12-27T23:37:48.899931925Z npm ERR! Failed at the angular-todo@0.0.0 start script.
2019-12-27T23:37:48.901243776Z npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
看起来docker映像中没有可用的ng
我正在使用GitHub操作来构建和部署应用程序,因此我没有访问docker容器本身的alias命令的权限。任何帮助都将不胜感激
源代码如下:
网站位于以下位置:
首先:Angular CLI是一种开发工具,而不是生产工具。您应该有一个构建应用程序的构建管道,然后是一个发布管道,用于将输出发布到应用程序服务 在生产环境中安装并运行agularcli不是一个好主意。原因之一是
ng-serve
使用webpack-dev-server
。这是一个开发服务器,不用于生产
此外:
即使使用--prod标志,也不希望在生产中使用ng serve
flag存在的原因是为了在本地模拟开发环境中的生产构建的编译步骤,以便在需要时简化开发过程
概要:使用ng serve进行开发,无论是否使用--prod,并使用生产就绪的web服务器进行部署
取自
有关如何部署的更多信息,请参阅
顺便说一句:如果您需要在机器上安装Angular CLI之类的工具,您应该使用例如npm install
来安装它