问题描述
我正在使用nx框架(https://nx.dev)创建一个angular + Nest应用程序。角度应用程序应为前端应用程序,而嵌套应用程序应为REST-API。我已经在“ Azure DevOps”中创建了一个git repo。
我通过以下方式创建此应用程序
docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e "ES_JAVA_OPTS=-Xms2g -Xmx2g" docker.elastic.co/elasticsearch/elasticsearch:7.9.2
此后,我有一个Angular和Nest应用程序。
我可以使用以下方式启动有角度的前端应用程序
npx create-nx-workspace@latest
? Workspace name (e.g.,org name) nxtest
? What to create in the new workspace angular-nest [a workspace with a full stack application (Angular + Nest)]
? Application name test-app
? Default stylesheet format CSS
和带有以下内容的Nest应用(REST-API)
nx serve test-app
可以在浏览器上使用api了。
下一步,我提交并将其推送到git repo。
我在Microsoft Azure中创建一个Web应用程序。
Settings Microsoft Azure Web-App
现在,我想创建一个CI / CD步骤。
在azure门户中...
- 选择部署中心
- 选择 Azure仓库
- 选择 Azure管道
- 选择我的组织,项目,存储库,分支,并作为Web应用程序框架NodeJS和“任务运行器”“无”。
Settings for Deployment as Azure Web-App
此后,我在“ Azure DevOps”项目中有了一个新的构建管道。
创建构建管道运行成功,但是构建定义不完整。
- 使用节点版本
- npm使用package.json运行安装
- 存档文件
- 紫色构建工件
Azure上的结果
- 所有文件均从git repo复制
- 使用iisnode创建一个web.config作为处理程序,路径为“ server.js”
但是没有启动javascript文件。
所以,我编辑构建管道。
Install application dependencies
Run Build 脚本“ buildall”-> nx run-many --target = build --all --prod
ng serve api
管道的运行完成后,我将这些文件保存在Web应用程序的wwwroot文件夹中。
- main.js
- main.js.map
- web.config
但是,如果我运行该应用程序或访问该URL,则始终会在控制台中出现以下错误。
Starting: build
==============================================================================
Task : npm
Description : Run an npm command. Use NpmAuthenticate@0 task for latest capabilities.
Version : 0.175.0
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/package/npm
==============================================================================
C:\windows\system32\cmd.exe /D /S /C "C:\hostedtoolcache\windows\node\12.13.0\x64\npm.cmd config list"
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.12.0 node/v12.13.0 win32 x64"
; environment configs
cache = "C:\\npm\\cache"
prefix = "C:\\npm\\prefix"
; node bin location = C:\hostedtoolcache\windows\node\12.13.0\x64\node.exe
; cwd = D:\a\1\s\nxtest
; HOME = C:\Users\VssAdministrator
; "npm config ls -l" to show all defaults.
C:\windows\system32\cmd.exe /D /S /C "C:\hostedtoolcache\windows\node\12.13.0\x64\npm.cmd run buildall"
> nxtest@0.0.0 buildall D:\a\1\s\nxtest
> nx run-many --target=build --all --prod
> NX Running target build for projects:
- test-app
- api
———————————————————————————————————————————————
> ng run api:build:production
Starting type checking service...
Using 2 workers with 2048MB memory limit
Hash: d814495e471a4bbc4f1b
Built at: 10/06/2020 8:40:04 AM
Entrypoint main = main.js main.js.map
chunk {0} main.js,main.js.map (main) 2.43 KiB [entry] [rendered]
> ng run test-app:build:production
chunk {} runtime.e227d1a0e31cbccbf8ec.js (runtime) 1.45 kB [entry] [rendered]
chunk {1} main.47f3572e3dd98212c211.js (main) 122 kB [initial] [rendered]
chunk {2} polyfills.9e86b32c42185429d576.js (polyfills) 36.1 kB [initial] [rendered]
chunk {3} styles.280e991c5992f8630bc9.css (styles) 0 bytes [initial] [rendered]
Date: 2020-10-06T08:40:42.853Z - Hash: 958a1c63d1211ca0510b - Time: 30858ms
———————————————————————————————————————————————
> NX SUCCESS Running target "build" succeeded
Finishing: build
我以前所有使Nestjs应用程序正常运行的尝试都是徒劳的。感谢您的帮助。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)