Skip to content

Instantly share code, notes, and snippets.

@theonlydaleking
Last active December 17, 2018 04:55
Show Gist options
  • Save theonlydaleking/0c48033799ac007fb99f14c22a984245 to your computer and use it in GitHub Desktop.
Save theonlydaleking/0c48033799ac007fb99f14c22a984245 to your computer and use it in GitHub Desktop.

Create a node server with es6 support

Step 1:

yarn add --dev @babel/core @babel/cli @babel/preset-env @babel/node nodemon

Step 2: Add build step:

add this to your package.json file

"scripts": {
   "dev": "nodemon --exec babel-node src/index.js",
   "build": "babel src --out-dir dist",
   "start": "node dist/index.js"
  },

this will run babel and output the files into a build folder. when you run yarn build it will serve the files when you run yarn start - this is for production it will deploy locally and rebuild the transpiled code when you run yarn dev

Step 3: .babelrc file

and in .babelrc

{
  "presets": ["@babel/preset-env"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment