When I run gcloud app deploy in Cloud Shell in my browser, I get an Error - Cannot find module '/srv/server.js' over and over. I also get a 500 server error when I view my app URL.
I have a basic Angular app with one lazy loaded path/component just for testing. I installed Angular Universal and then I built my app locally using the commands ng build --prod && npm run build:ssr
which put the following files in the dist folder:
- browser
- all the usual Angular files like index.html etc etc
- server
- main.js
- app.yaml
- package.json
- prerender.js
- server.js
I have created a basic app on Google App Engine and logged into my app by clicking the Cloud Shell button in my App Engine console.
I then clicked the editor button where you can browse files and write commands in your browser window.
Inside my app.yaml file I have:
runtime: nodejs10
In my package.json file I have:
{
"scripts": {
"start": "node server.js"
}
}
So in Cloud Shell I go to the root directory is where all my files are and where my app.yaml file is and then I run gcloud app deploy
.
It then uploads my files to the storage bucket and then runs the node server.js script. Nothing happens in the cloud shell console but when I look in the error log gcloud app logs tail -s default
and I go to my app URL, it shows a 500 Server Error and logs Error: Cannot find module '/srv/server.js' over and over.
internal/modules/cjs/loader.js:638
Error: Cannot find module '/srv/server.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Function.Module._load (internal/modules/cjs/loader.js:562:25) at Function.Module.runMain (internal/modules/cjs/loader.js:831:12) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
Any help would be greatly appreciated.
Thank you!
I expect to see my Angular app running on the App Engine Cloud URL.