【NodeJS】NodeJS、ES6、Babel初步

1、安装node-v8.10.0-x64.msi

2、npm init -y

3、npm install --save express

4、npm install --save-dev babel-cli babel-preset-es2015 rimraf

5、package.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
  "name": "vtk-js-new",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "rimraf dist/ && babel ./ --out-dir dist/ --ignore ./node_modules,./.babelrc,./package.json,./npm-debug.log --copy-files",
    "start": "npm run build && node dist/index.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express": "^4.16.2"
  },
  "devDependencies": {
    "babel-cli": "^6.26.0",
    "babel-preset-es2015": "^6.24.1",
    "rimraf": "^2.6.2"
  }
}

6、.babelrc

1
2
3
{
"presets": ["es2015"]
}

7、index.js

1
2
3
4
5
6
7
8
9
10
11
import express from 'express';
 
const app = express()
 
app.get('/', function (req, res) {
  res.send('Hello World!')
})
 
app.listen(3000, function () {
  console.log('Example app listening on port 3000!')
})

8、文件夹结构

8、npm start

9、运行效果

 参考资料:http://www.cnblogs.com/weschen/p/7159307.html

posted @   咸鱼翻身  阅读(2038)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
历史上的今天:
2016-03-09 SSH
点击右上角即可分享
微信分享提示