这是indexloc提供的服务,不要输入任何密码
Skip to content

resultakak/nodejs-es6-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Topics

Resources

Stars

Watchers

Forks

Packages