Skip to content

Instantly share code, notes, and snippets.

@h3ct0rjs
Forked from rahman541/ES6-Setup.md
Last active April 7, 2019 23:19
Show Gist options
  • Select an option

  • Save h3ct0rjs/2fa0daa7d4eb7f880e8f805fd5520fdf to your computer and use it in GitHub Desktop.

Select an option

Save h3ct0rjs/2fa0daa7d4eb7f880e8f805fd5520fdf to your computer and use it in GitHub Desktop.
ES6 Setup with nodemon

ES6 Setup

npm init -y
npm i --save-dev nodemon
npm add babel-preset-env babel-cli

Create a .babelrc config in your project root. Insert the following

{
  "presets": ["env"]
}

In package.json add this to scipts:

"dev": "nodemon --exec babel-node index.js"

To run: npm run dev

{
"name": "test-api",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "npm run prod",
"server": "nodemon --exec babel-node ./src/bin/www",
"server:prod": "node ./dist/bin/www",
"dev": "NODE_ENV=development npm-run-all server",
"clean": "rimraf dist",
"build": "babel ./src --out-dir dist",
"prod": "NODE_ENV=production npm-run-all clean build server:prod"
},
"dependencies": {
"cookie-parser": "^1.4.4",
"debug": "^2.6.9",
"express": "^4.16.4",
"morgan": "^1.9.1",
"nodemon": "^1.18.10",
"npm-run-all": "^4.1.5",
"rimraf": "^2.6.3"
},
"devDependencies": {
"@babel/cli": "^7.4.3",
"@babel/core": "^7.4.3",
"@babel/node": "^7.2.2",
"@babel/preset-env": "^7.4.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment