Making an enviroment to learn ES6 with babel
·1 分で読めます
This is a just memo for me who is a beginner of front-end development.
First of all, install nodejs v4.4.0.
$ brew install homebrew/versions/node4-lts
$ node -v
v4.4.0Put package.json into a current directory. DO NOT forget to add babel-preset-es2015.
{
"name": "hello",
"version": "1.0.0",
"engines": {
"node": "4.4.0",
"npm": "3.8.2"
},
"devDependencies": {
"babel-cli": "^6.0.0",
"babel-preset-es2015": "^6.6.0"
}
}Run npm install
$ npm install Put .babelrc to tell babel using es2015 preset.
echo '{ "presets": ["es2015"] }' > .babelrcPut hello.js.
"use strict";
class Hello {
say(message) {
console.log(message);
}
}
new Hello().say("hello");Transpile hello.js and run it.
$ node_modules/.bin/babel hello.js | node
hello関連記事
Parsing MySQL's URL in Python3
2015-12-14
Logging into dmm.com by Selenium
2015-10-26