无法使用生态系统.config.js在pm2中设置环境React app webpack app

时间:2018-12-03 12:45:07

标签: node.js reactjs webpack pm2

我的package.json文件如下所示,用于在pm2中运行的hgweb应用 package.json

{
  "name": "hgweb",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "antd": "^3.10.4",
    "axios": "^0.18.0",
    "emoji-mart": "^2.8.1",
    "env-cmd": "^8.0.2",
    "express": "^4.16.3",
    "glamor": "^2.20.40",
    "glamorous": "^4.13.1",
    "jsonwebtoken": "^8.3.0",
    "moment": "^2.22.2",
    "path": "^0.12.7",
    "query-string": "^6.2.0",
    "react": "^16.4.2",
    "react-datepicker": "^1.6.0",
    "react-dom": "^16.4.2",
    "react-icons": "^3.0.5",
    "react-image-gallery": "^0.8.11",
    "react-input-mask": "^2.0.4",
    "react-input-range": "^1.3.0",
    "react-load-script": "0.0.6",
    "react-places-autocomplete": "^7.2.0",
    "react-redux": "^5.0.7",
    "react-responsive-modal": "^3.4.0",
    "react-router": "^4.3.1",
    "react-router-dom": "^4.3.1",
    "react-scripts-ts": "2.17.0",
    "react-switch": "^3.0.4",
    "redux": "^4.0.0",
    "redux-devtools-extension": "^2.13.5",
    "redux-form": "^7.4.2",
    "redux-thunk": "^2.3.0",
    "revalidate": "^1.2.0",
    "socket.io-client": "^2.1.1"
  },
  "scripts": {
    "build": "react-scripts-ts build",
    "publish": "npm run build && serve -s build",
    "test": "react-scripts-ts test --env=jsdom",
    "eject": "react-scripts-ts eject",
    "start": "env-cmd .env.dev react-scripts-ts start",
    "start:staging": "env-cmd .env.staging npm run build && node src/server/server.js",
    "start:prod": "env-cmd .env.prod npm run build && node src/server/server.js",
    "deploy:staging": "npm install && npm run start:staging",
    "deploy:prod": "npm install && npm run start:prod"
  },
  "devDependencies": {
    "@types/emoji-mart": "^2.8.1",
    "@types/jest": "^23.3.1",
    "@types/jsonwebtoken": "^7.2.8",
    "@types/node": "^10.9.4",
    "@types/query-string": "^6.1.1",
    "@types/react-datepicker": "^1.1.7",
    "@types/react-dom": "^16.0.7",
    "@types/react-image-gallery": "^0.8.3",
    "@types/react-input-mask": "^2.0.1",
    "@types/react-places-autocomplete": "^6.1.3",
    "@types/react-redux": "^6.0.7",
    "@types/react-router-dom": "^4.3.0",
    "@types/redux-form": "^7.4.7",
    "@types/socket.io-client": "^1.4.32",
    "typescript": "^3.0.3"
  }
}

无法为使用以上package.json文件的react应用设置环境。我的pm2生态系统.config.json文件如下所示

module.exports = {
  apps : [
    {
     name      : "HGBackend",
     cwd       : "hgbackend/server",
     script    : "server.js",
     env       :
         {
            "PORT": 3000,
            "NODE_ENV": "staging"
        }
    },
    {
    name       : "HGBlockchain",
    cwd        : "hgblockchain/localgrammes",
    script     : "index.js"
   // args       : "start:staging"
   // instances  : 4,
   // exec_mode  : "cluster"
  },
  {
    name   : "HGWeb",
    cwd    : "hgweb/src/server",
    script : "server.js",
    env : {
        NODE_ENV: 'staging'
      },
    description: ""
  }

]}

我无法在pm2中设置React应用环境。它适用于后端和区块链应用程序。任何人都可以建议我在pm2中使用webpack运行react app

0 个答案:

没有答案