React-starter-kit: babe-node isn't recommended for production use

Created on 22 May 2017  路  3Comments  路  Source: kriasoft/react-starter-kit

Package.json mentions using babel-node for serving node server.

Refer https://babeljs.io/docs/usage/cli/#babel-node

### Not meant for production use
You should not be using babel-node in production. It is unnecessarily heavy, with high memory usage due to the cache being stored in memory. You will also always experience a startup performance penalty as the entire app needs to be compiled on the fly.

Most helpful comment

@eduwass Yes, it's for development usage.
After you build it, it's create build/package.json without dev dependencies

In my case, I use 3 stage in a project.

  1. Development

    • NODE_ENV=development

    • Use yarn run start to run application

    • Use yarn run start -- --release to check on production mode

  1. Staging (production testing)

    • NODE_ENV=production
    • Use yarn run start -- --release to run application
    • Build using yarn run build -- --release then upload to production (read more in tools/deploy.js)
  2. Production (in this stage, we don't need babel-node anymore)

    • NODE_ENV=production
    • Use node server.js to run application

All 3 comments

Yes, but in package.json babel-cli just for devDependencies. Of course it won't be used in production.

For production, you can build with

$ yarn run build -- --release

then, run the application in build folder

$ node build/server.js

or, run it with pm2, nodemon or forever

@ucay sorry if a noob question, but according to the package.json doesn't using:

yarn run build -- --release

Actually execute:

"build": "babel-node tools/run build"

Which basically relies on babel-node?

@eduwass Yes, it's for development usage.
After you build it, it's create build/package.json without dev dependencies

In my case, I use 3 stage in a project.

  1. Development

    • NODE_ENV=development

    • Use yarn run start to run application

    • Use yarn run start -- --release to check on production mode

  1. Staging (production testing)

    • NODE_ENV=production
    • Use yarn run start -- --release to run application
    • Build using yarn run build -- --release then upload to production (read more in tools/deploy.js)
  2. Production (in this stage, we don't need babel-node anymore)

    • NODE_ENV=production
    • Use node server.js to run application
Was this page helpful?
0 / 5 - 0 ratings