Search code examples
reactjsamazon-web-servicespm2

Deploy react app to AWS with pm2


I am trying to deploy react app to AWS following this tutorial https://medium.com/@sgobinda007/setting-up-react-redux-application-for-production-and-hosting-in-aws-ec2-8bbb8bf3c643 my app is slightly different and when I run pm2 start ecosystem.config.js --env production I get that app status is online but on pm2 show status is errored with the following output: /home/ubuntu/www/react/tools/distServer.js:4 import browserSync from 'browser-sync'; ^^^^^^ | | SyntaxError: Unexpected token import my ecosystem.config.js file looks like this:

module.exports = {
  apps : [
      {
        name: "blockchainwallet",
        script: "tools/distServer.js",
        watch: true,
        env: {
            "PORT": 8080,
            "NODE_ENV": "development"
        },
        env_production: {
            "PORT": 3000,
            "NODE_ENV": "production",
        }
      }
  ]
}

could you give me any suggestions in order to fix this bug?


Solution

  • Check your webpack config and the node version of your environment, as the error you mention is a common error for not supported ES6 syntax.

    import is used in ES6, you must use require in ES5