Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Cannot find module '/workspace/server.js'

enter image description hereI am trying to deploy a create-react-app https://github.com/lrtico/allowance-tracker I developed to Google Cloud and am getting this error in Error Reporting when visiting the web page https://allowance-tracker-287504.wn.r.appspot.com/:

Error: Cannot find module '/workspace/server.js'
  at Function.Module._resolveFilename (loader.js:636)
  at Function.Module._load (loader.js:562)
  at Function.Module.runMain (loader.js:831)
  at startup (internal/bootstrap/node.js:283)
  at bootstrapNodeJSCore (internal/bootstrap/node.js:623)

As a test, I deployed the same build to Azure and the app runs perfectly. Any ideas on what I am missing?

like image 331
Jackson Powell Avatar asked Oct 29 '25 08:10

Jackson Powell


2 Answers

I was right. I tested and I successfully deployed on App Engine by updating the app.yaml

  1. Start by doing a npm run build
  2. Then update the app.yaml file like this
runtime: nodejs10

handlers:
  - url: /
    static_files: build/index.html
    upload: build/index.html

  - url: /
    static_dir: build
  1. deploy your app gcloud app deploy
like image 124
guillaume blaquiere Avatar answered Oct 30 '25 23:10

guillaume blaquiere


I experienced the same error. It was because I mistakenly removed the start script.

From the GCP AppEngine doc :

By default, the runtime starts your application by running node server.js. If you specify a start script in your package.json file, the runtime runs the specified start script instead

The other way is as defined here :

You can override this behavior by specifying a script in the entrypoint field in app.yaml. Instead of running node server.js or a start script, the runtime starts your application with the command you specify in entrypoint

See : https://cloud.google.com/appengine/docs/standard/nodejs/runtime#application_startup

like image 21
John Doe Avatar answered Oct 31 '25 01:10

John Doe