我想将我的Angular应用程序部署到Cloud-Foundry。
在下面,您可以在my dist文件夹中找到当前的package.json:
{
"name": "showroom-app",
"version": "0.0.0",
"engines": {
"node": "14.15.3",
"npm": "6.13.7"
},
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build && cp -r ./cf/* ./dist",
"test": "echo \"Error: no test specified\"",
"lint": "ng lint",
"e2e": "ng e2e"
},
"dependencies": {
"@angular/animations": "~9.1.0",
"@angular/cli": "~9.1.0",
"@angular/compiler-cli": "~9.1.0",
"@angular/common": "~9.1.0",
"@angular/compiler": "~9.1.0",
"@angular/core": "~9.1.0",
"@angular/forms": "~9.1.0",
"@angular/platform-browser": "~9.1.0",
"@angular/platform-browser-dynamic": "~9.1.0",
"@angular/router": "~9.1.0",
"karma-coverage": "^2.0.3",
"rxjs": "~6.5.4",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.901.0",
"@angular/language-service": "~9.1.0",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^12.11.1",
"codelyzer": "^5.1.2",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^4.4.1",
"karma-chrome-launcher": "^3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "^3.0.3",
"karma-jasmine-html-reporter": "^1.4.2",
"protractor": "~5.4.3",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~3.8.3"
}}
我的manifest.yml:
---
applications:
- name: npmPipeline
buildpack: https://github.com/cloudfoundry/nodejs-buildpack
memory: 2048MB
disk_quota: 2048MB
dea_next.staging_disk_limit_mb:
description: "Disk limit in MB for staging tasks"
default: 4096
instances: 1
timeout: 360
random-route: true
path: ./在dist文件夹内执行cf push后,出现以下错误:
2021-01-05T14:44:50.87+0100 [APP/PROC/WEB/0] OUT > hello-world@0.0.0 start /home/vcap/app
2021-01-05T14:44:50.87+0100 [APP/PROC/WEB/0] OUT > ng serve
2021-01-05T14:44:51.53+0100 [APP/PROC/WEB/0] ERR The serve command requires to be run in an Angular project, but a project definition could not be found.
2021-01-05T14:44:51.54+0100 [APP/PROC/WEB/0] ERR npm ERR! code ELIFECYCLE
2021-01-05T14:44:51.54+0100 [APP/PROC/WEB/0] ERR npm ERR! errno 1
2021-01-05T14:44:51.54+0100 [APP/PROC/WEB/0] ERR npm ERR! hello-world@0.0.0 start: `ng serve`
2021-01-05T14:44:51.54+0100 [APP/PROC/WEB/0] ERR npm ERR! Exit status 1
2021-01-05T14:44:51.54+0100 [APP/PROC/WEB/0] ERR npm ERR!
2021-01-05T14:44:51.54+0100 [APP/PROC/WEB/0] ERR npm ERR! Failed at the hello-world@0.0.0 start script.
2021-01-05T14:44:51.54+0100 [APP/PROC/WEB/0] ERR npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-01-05T14:44:51.67+0100 [APP/PROC/WEB/0] ERR npm ERR! A complete log of this run can be found in:
2021-01-05T14:44:51.67+0100 [APP/PROC/WEB/0] ERR npm ERR! /home/vcap/app/.npm/_logs/2021-01-05T13_44_51_544Z-debug.log我已经通过更新@ followed this proposed solution /cli来更新了角度,但是什么都没有改变。
你知道怎么解决这个问题吗?谢谢!:)
干杯,马蒂亚斯
发布于 2021-01-06 22:21:53
好了,这里有几件事。
dea_next.staging_disk_limit_mb: description:“分段任务磁盘限制( MB )”默认值: 4096
去掉它就好。disk_quota: 1024M是您为应用程序设置磁盘配额的方式,您也可以使用它,它同时适用于登台和运行时。
nodejs_buildpack,要么引用一个发布标签,比如buildpack: https://github.com/cloudfoundry/nodejs-buildpack#v1.7.39。这将确保你得到更可靠的东西。-p标志或path:来更改推入的内容。例如,如果您使用的是nodejs构建包,您可能希望从package.json所在的项目根目录进行推送。这是因为nodejs构建包需要package.json和所有东西来运行您的应用程序。但是,如果使用静态文件构建包,则需要从dist/目录(或构建的/prod文件结束的任何位置)进行推送。
在使用静态文件构建包时,请启用push state support。这将配置Nginx以支持客户端路由和花哨的URL。
https://stackoverflow.com/questions/65580306
复制相似问题