0

I have been attempting to deploy an Angular2 application with Google App Engine and have been running into issues. I get the following error when trying to deploy:

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

The error seems to point to @angular/material given the line .../position/overlay-position-builder.js.

I built the app using @angular-cli.

There is nothing of value in the logs that I can see.

Any ideas on what the issue might be and how to resolve this?

2
  • Can you share the steps you've taken to reach to the issue? Commented Apr 4, 2017 at 20:46
  • To get here I've just been running gcloud app deploy. I did already have to move "@angular/cli": "^1.0.0" into dependencies in addition to devDependencies in package.json as there was an issue with not having @angular-cli installed and the script trying to run ng serve and failing. So just to make sure that there was no issue with my app in Google Cloud I downloaded and deployed the cloud-cardboard-viewer sample project at codelabs.developers.google.com/codelabs/cloud-cardboard-view‌​er/… and that deployed without issue. Again, I have no issues running locally. Commented Apr 5, 2017 at 0:08

1 Answer 1

1

ISSUE: The ERROR: (gcloud.app.deploy) Error Response: [9] is typically caused by a dependency issue that results in an error of not found.

This similar issue, or sh: 1: ng: not found, has been reported and worked-around by using creating a Dockerfile here.

In this original post, it appears that yarn start v0.21.3 is the issue.


SOLUTION: An Angular2 project created by using the angular-cli will contain the root package.json file with a devDependencies section like the example below:

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

NOTE: To get any other dependencies, like @angular/material and commands like yarn start v0.21.3 to work. The Dockerfile must include the commands to install those dependencies via command line.

Create an app.yaml and Dockerfile within the same path of the package.json file like the example below:

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

The app.yaml file will need the following settings: (app.yaml documentation):

# [start app_yaml]
  runtime: custom
  env: flex

The Dockerfile will need all the commands a user could call on the command line to assemble an image.

Note: npm install -g @angular/cli command being ran in the example below:

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"] 

Deploy the app to your google cloud App Engine: gcloud app deploy

(gcloud documentation)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.