Harmonious Node.js
Setting up NVM w/ ZSH
Execute the following1
2
3
4
5mkdir -p ~ZSH_CUSTOM/plugins
cd ~ZSH_CUSTOM/plugins
git clone git://github.com/rummik/nvm-zsh.git
cd nvm-zsh
git submodule update --init
Then edit the plugins array in your ~/.zshrc
to include nvm-zsh
so that it
looks somewhat like this: plugins=(nvm-zsh history-substring-search git osx ruby)
Installing a newer version of node
- Run
nvm ls-remote
to determine the latest version of Node - Install it:
nvm install v0.11.15
- Run
node --v8-options | grep harmony
to determine which harmony features are supported - Start using harmony features by running your code with
node --harmony foo.js
Gotchas w/ Arrow Functions in ES6/Harmony
Note that the following does not work:1
2
3
4
5
6
7
8
9function ES6Example(){}
ES6Example.prototype.foo = function(bar){
return ((baz) => {
this.bar = baz
})(bar)
}
var es6Example = new ES6Example
es6Example.foo('qux')
console.info(es6Example.bar) //undefined
But this does:1
2
3
4
5
6
7
8function ES6Example(){
this.foo = baz => {
this.bar = baz
}
}
var es6Example = new ES6Example
es6Example.foo('qux')
console.info(es6Example.bar) // 'qux'