resultakak / nodejs-es6-starter

NodeJs ES6 Babel Nodemon Template

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nodejs ES6 Example

npm init

touch sum.js index.js

npm install --save-dev @babel/core @babel/cli @babel/preset-env @babel/node

npm i --save-dev nodemon

touch .babelrc
// .babelrc
{
  "presets": [
    "@babel/preset-env"
  ]
}
//sum.js

function add(a, b) { 
  return a + b;
}

export default add; // ES6 export
//index.js

import add from "./sum"; //ES6 import

console.log(add(3, 4)); //This should print 7 in the console
// package.json
"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "nodemon --exec node_modules/.bin/babel-node index.js"
  }
npm start
// .npmrc
//npm.pkg.github.com/:_authToken=TOKEN
@OWNER:registry=https://npm.pkg.github.com

https://docs.github.com/en/actions/guides/publishing-nodejs-packages https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry

About

NodeJs ES6 Babel Nodemon Template


Languages

Language:JavaScript 100.0%