1
votes

I'm trying to deploy a simple Node.js express application to Google App Engine (flex environment).

The application runs great locally. When I try to deploy to App Engine, I get the following error:

Error: Cannot find module './app/models/xyz'

My app directory structure looks like:

server.js

app/models/xyz.js

In server.js, I require the xyz.js file as follows:

const Xyz = require('./app/models/xyz');

If I move the xyz.js file to the same root folder as server.js, everything deploys and works great.

This is the first node.js app that I try to deploy to Google App Engine. Do I need to configure the path to app/models/xyz.js in my app.yaml? None of the reference applications seem to require this?

1
Did you ever fix this?user5280885

1 Answers

0
votes

For small, simple projects, all the app's files can live in one directory. You are right, you may need to configure the path to "app/models/xyz.js" in your app.yaml, or rather using more than one *.yaml file, as described in the Organizing Configuration Files document.