繁体   English   中英

在Google Cloud上部署Angular2应用时出错

[英]Error deploying Angular2 app on Google Cloud

我一直在尝试使用Google App Engine部署Angular2应用程序,并且遇到了问题。 尝试部署时出现以下错误:

Updating service [default]...failed.                                                                                                          
ERROR: (gcloud.app.deploy) Error Response: [9] 
Application startup error:
yarn start v0.21.3
$ ng serve 
** NG Live Development Server is running on http://localhost:8080 **
 52% building modules 357/395 modules 38 active .../position/overlay-position-builder.js

给定.../position/overlay-position-builder.js行,该错误似乎指向@angular/material

我使用@angular-cli构建了该应用程序。

我看到的日志中没有任何价值。

关于这个问题可能是什么以及如何解决这个问题的任何想法?

问题: ERROR: (gcloud.app.deploy) Error Response: [9]通常是由依赖项问题引起的,导致not found错误。

已经通过使用在此处创建Dockerfile的方式报告并解决了这个类似的问题,或sh: 1: ng: not found

在此原始帖子中,似乎出现了yarn start v0.21.3


解决方案:使用angular-cli创建的Angular2项目将包含具有以下程序的devDependencies部分的根package.json文件:

"devDependencies": {
   "@angular/cli": "1.4.2",
   ...
   ...
},

注意:要获取其他依赖关系,例如@angular/material和类似yarn start v0.21.3命令,请yarn start v0.21.3 Dockerfile必须包含用于通过命令行安装这些依赖项的命令。

在package.json文件的相同路径内创建一个app.yamlDockerfile ,如下例所示:

angular2-example-app
├── e2e
├── node_modules
├── src
├── package.json
├── app.yaml 
├── Dockerfile

app.yaml文件将需要以下设置:( app.yaml文档 ):

# [start app_yaml]
  runtime: custom
  env: flex

Dockerfile将需要用户可以在命令行上调用的所有命令来组装映像。

注意:在以下示例中运行了npm install -g @angular/cli命令:

FROM alpine:latest
MAINTAINER yourname

# update alpine linux
RUN apk update && apk upgrade && \ 
    apk add nodejs && \
    # may comment this line in my computer.
    apk add nodejs-npm && \
    npm install -g @angular/cli

# add source code to images
ADD . /angular2-example-app

# switch working directory
WORKDIR /angular2-example-app

# install dependencies
RUN npm install

# expose port 4200
EXPOSE 4200 

# run ng serve on localhost
CMD ["ng","serve", "--host", "0.0.0.0", "--disable-host-check"] 

将应用程序部署到您的Google Cloud App Engine: gcloud app deploy

gcloud文档

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM