Skip to content

Instantly share code, notes, and snippets.

@makkaba
Last active June 10, 2019 05:00
Show Gist options
  • Save makkaba/0934312f075c886271ae685dd1d9016c to your computer and use it in GitHub Desktop.
Save makkaba/0934312f075c886271ae685dd1d9016c to your computer and use it in GitHub Desktop.
node_setup_2018

설치 (install)

npm install --save cors express cors body-parser lodash mysql
npm install --save-dev nodemon  
npm install --save-dev @babel/core @babel/preset-env @babel/cli @babel/node

파일 구조 (structure)

.
├── .babelrc
├── package.json
├── dist
└── src
    └── index.js

.babelrc

{
    "presets": ["@babel/preset-env"]
}

package.json

...
 "scripts": {
    "start": "nodemon --exec babel-node src/index.js",
    "build": "babel src -d dist",
    "serve": "node dist/index.js"
  },
...

src/index.js

var express = require('express');
var bodyParser = require('body-parser');
var cors = require('cors');
var app = express();
app.use(cors());
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json()); 

app.get('/', function (req, res) {
  res.send('Hello World!');
});

app.listen(3000, function () {
  console.log('Example app listening on port 3000!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment