1

I deployed a next.js application to the App Engine Standard and I get 500 error. In StackDriver the error is "/bin/sh: 1: server.js: not found"

but server.js exists in the app:

enter image description here I'm serving up my project on port 3000

Package.json is like this:

{
   "name": "supplychain",
   "version": "1.0.0",
   "description": "",
   "main": "index.js",
   "scripts": {
     "test": "mocha",
     "dev": "node server.js",
     "start": "NODE_ENV=production server.js",
     "transpile": "babel src -d dist --copy-files",
     "prepublishOnly": "npm run transpile",
     "build": "next build",
     "deploy": "gh-pages -d examples/dist",
   },
   "author": "",
   "license": "ISC",
   "dependencies": {
     "@babel/polyfill": "^7.2.5",
     "fs-extra": "^7.0.1",
     "ganache-cli": "^6.4.1",
     "mocha": "^5.2.0",
     "next": "^4.1.1",
     "next-routes": "^1.4.2",
     "radium": "^0.25.1",
     "react": "^16.8.4",
     "react-dom": "^16.8.4",
     "semantic-ui-react": "^0.82.5",
     "solc": "^0.4.25",
     "truffle-hdwallet-provider": "0.0.3",
     "web3": "^1.0.0-beta.35"
  },
    "devDependencies": {
      "@babel/cli": "^7.2.3",
      "@babel/core": "^7.2.2",
      "@babel/preset-env": "^7.3.1",
      "babel": "^6.23.0",
      "babel-cli": "^6.26.0",
      "babel-preset-es2015": "^6.24.1",
      "css-loader": "^2.1.0",
      "html-webpack-plugin": "^3.2.0",
      "npm-install-webpack-plugin": "^4.0.5",
      "terser-webpack-plugin": "^1.3.0",
      "uglifyjs-webpack-plugin": "v1.0.0-beta.1",
      "webpack": "^4.35.0",
      "webpack-cli": "^3.3.4",
      "webpack-dev-server": "^3.7.2"
  }
}

and app.yaml is like:

# [START app_yaml]
runtime: nodejs8
# [END app_yaml]

Can somebody help me find the problem?

parastoo
  • 372
  • 1
  • 4
  • 20

1 Answers1

1

Change this line:

"start": "NODE_ENV=production server.js",

To:

"start": "NODE_ENV=production node server.js",
John Hanley
  • 74,467
  • 6
  • 95
  • 159
  • Thank you. That solved the problem but I get another error: "Could not find a valid build in the '.next' directory! Try building your app with 'next build' before starting the server." and with npm run build I get "Error: commons.js from UglifyJs Unexpected token name «i», expected punc «;»" error. Do you have any idea? – parastoo Jun 22 '19 at 19:53
  • Create a new question with details. We want questions that everyone can benefit from. – John Hanley Jun 22 '19 at 20:05
  • Sure. You're right. I did post that question too but unfortunately, I didn't get any answers yet. This is the [link](https://stackoverflow.com/questions/56709089/cannot-fix-unexpected-token-name-i-expected-punc-from-uglifyjs?noredirect=1#comment99987391_56709089) – parastoo Jun 22 '19 at 20:09
  • I don't know the answer to that one. You have not posted enough of your project to reproduce the error. I would create a GitHub repo and provide a link in your question. This will make it easier to figure out. – John Hanley Jun 22 '19 at 20:54
  • Thank you for the suggestion. I added the link to GitHub repo. – parastoo Jun 23 '19 at 03:02