Boiler-plate code to get started with Nodejs and babel.
npm init -y
npm i -D @babel/core @babel/node @babel/preset-env
{
"presets": ["@babel/preset-env"]
}
npm i -D prettier
{
"printWidth": 100,
"singleQuote": true
}
npm i -D eslint eslint-config-airbnb-base eslint-config-prettier eslint-plugin-import eslint-plugin-prettier
module.exports = {
env: {
browser: true,
es6: true
},
extends: ['airbnb-base', 'prettier'],
plugins: ['prettier'],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly'
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module'
},
rules: {
'prettier/prettier': ['error']
}
};
npm i -D nodemon
{
"scripts": {
"test": "npm test",
"start": "nodemon --exec babel-node src/index.js",
"debug": "nodemon --exec babel-node src/index.js --inspect ./bin/www",
"build": "babel src --out-dir dist",
"serve": "node dist/index.js"
}
}
npm start
paste following code to .vscode/launch.json file.
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Node: Nodemon",
"processId": "${command:PickProcess}",
"restart": true,
"protocol": "inspector"
}
]
}
npm run debug
Press F5
and select running nodemon process.
.
+-- src
+-- index.js
+-- .babelrc
+-- .eslintrc.js
+-- .prettierrc
+-- package.json