nnode - a nicer node
So nice, you'd introduce it to your parents.
nnode executes .js and .ts files with node + babel.
It works just like
For using the
nnode cli, install the package globally:
npm install -g nnode
When using the
nnode package as
require('nnode'), install the package as a dependency:
npm install nnode --save
;const x = this: 'this' very: 'really' ;const very = x;console;
If you try running
node run-me.js, you'll see:
SyntaxError: Unexpected token import
That's not very nice, try something nicer, like
Awww, this is really nice.
You can also
require('nnode') which works just like require('babel-register') without needing to setup .babelrc and installing babel presets, plugins and other non-niceties.
Useful when running stuff with
If you're using typescript, you should
Why not babel-node section:
- babel-node requires babel presets, plugins and .babelrc file to be present in the local project
- you don't want to keep finding and installing them one by one every time you want to run something
- sometimes, a combination of plugins and presets or their versions just doesn't work
- this is why nnode depends on them by the exact patch version
nnode is called with
--transpile flag, it goes into transpilation mode.
This allows us to transpile a directory for older node (v.6.0) which is useful for npm publish.
So, this call:
will transpile every .js file within the
src directory into the
Build directory and all the subdirectories will be created if necessary.
Generated code will be targeted for node version 6.0.