无法在Google App Engine上托管React应用

时间:2017-07-20 23:29:30

标签: node.js reactjs google-app-engine deployment

我是这里的Google App Engine新手。努力将我的第一个应用程序部署到平台上。当我尝试时,我收到以下错误消息:

The command '/bin/sh -c npm install --unsafe-perm ||   ((if [ -f npm-debug.log ]; then       cat npm-debug.log;     fi) && false)' returned a non-zero code: 1
ERROR
ERROR: build step "gcr.io/cloud-builders/docker@sha256:b085f9e5583624eace9c9ba45097afc12123cf5f145703c693c32264c90bbbe0" failed: exit status 1
ERROR: gcloud crashed (AttributeError): 'module' object has no attribute 'HttpErrorPayload'

的app.yaml:

env: flex
runtime: nodejs

的package.json:

{
  "name": "react-boilerplate",
  "version": "1.0.0",
  "description": "Minimal boilerplate for react",
  "main": "index.js",
  "scripts": {
    "dev": "webpack-dev-server --progress --inline --colors --hot --config ./webpack.config.js",
    "postinstall": "NODE_ENV='production' webpack -p",
    "start": "node server.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "babel": {
    "presets": [
      "es2015",
      "react",
      "stage-2"
    ]
  },
  "engines": {
    "node": "6.11.0",
    "npm": "3.10.10"
  },
  "devDependencies": {
    "babel-core": "^6.24.1",
    "babel-loader": "^7.0.0",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "babel-preset-stage-2": "^6.24.1",
    "css-loader": "^0.28.0",
    "node-sass": "^4.5.2",
    "sass-loader": "^6.0.5",
    "style-loader": "^0.16.1",
    "webpack": "^3.0.0",
    "webpack-dev-server": "^2.4.5"
  },
  "dependencies": {
    "axios": "^0.16.2",
    "d3": "^4.9.1",
    "react": "^15.5.4",
    "react-dom": "^15.5.4",
    "react-redux": "^5.0.5",
    "redux": "^3.7.1",
    "redux-thunk": "^2.2.0"
  }
}

server.js:

const express = require('express');
const path = require('path');
const port = process.env.PORT || 8080;
const app = express();

app.use(express.static(__dirname));

app.get('*', (req, res) => {
  res.sendFile(path.resolve(__dirname, 'index.html'));
});

app.listen(port);
console.log('Server started');

这就是我的文件夹目录:

enter image description here

我做对了吗?

1 个答案:

答案 0 :(得分:0)

能够通过将devDependencies中的所有模块移动到dependencies来解决此问题!