Node.js App Deployment to Google App Engine

71 views
Skip to first unread message

Bill Jones

unread,
Apr 7, 2016, 7:35:28 PM4/7/16
to Google App Engine

Hello,

I am evaluating Google's App Engine. In an attempt to learn more about it, I am trying to deploy an existing Node app. My app has a structure that looks like this:

/config
/data
/public
/src
  /views
  app.js
app.yaml

My app is much larger. The main thing I'm trying to point out here is that my app.js isn't in the root directory. My question is, how can I deploy this app? Is there a setting in the app.yaml file I can set to point out that my app is actually located in the "src" directory?

I'd hate to have to restructure my entire app.

Thanks

Nicholas (Google Cloud Support)

unread,
Apr 15, 2016, 12:23:17 PM4/15/16
to Google App Engine
Thanks for posting your questions here. Happy to hear you're interested in trying Nodejs on Google App Engine. The Nodejs runtime on Google App Engine uses npm to package, install and run Nodejs servers. This requires the use of a package.json file to specify your application's dependencies and scripts.

When uploaded, the runtime will attempt to execute npm start which will look for and execute the start command specified in your package.json file. It commonly looks something like this:

"scripts": {
  "start": "node app.js"
}

For your use case, you could simply add the directory before app.js like so:

"scripts": {
  "start": "node src/app.js"
}

Feel free to review some of the linked material above and inspect the Hello World example to see it in practice. Hope this helps!
Reply all
Reply to author
Forward
0 new messages