brew install node
installed as part of node
npm i -g npm@latest
https://babeljs.io/docs/setup#installation
npm i -D babel-cli babel-preset-env babel-watch
Update the package.json
scripts to include:
"scripts": {
"build": "babel src -d dist",
"start": "babel-watch src"
},
Add a .babelrc
file:
{
"presets": ["env"]
}
babel-node
is a CLI that works exactly the same as the Node.js CLI, with the added benefit of compiling with Babel presets and plugins before running it.
npm install --save-dev @babel/core @babel/node
"scripts": {
"start": "babel-node src"
}
Reload your babel-node
app on JS source file changes. And do it fast.
npm install --save-dev babel-watch
"scripts": {
"start": "babel-watch src"
}
https://www.39digits.com/configure-prettier-and-eslint-in-visual-studio-code/
We also configure Prettier to ensure proper format on git commit
.
npm i -D prettier lint-staged husky
Update the package.json
to include:
{
"scripts": {
"precommit": "lint-staged"
},
"lint-staged": {
"*.{js,json,css,md}": ["prettier --write", "git add"]
}
}
A node project with Babel, ESLint, Prettier, Jest, ...
npm install --global yo generator-node-oss
yo node-oss