Skip to main content

Node

Memory Allocation​

NODE_OPTIONS=--max-old-space-size=4096 node xyz.js

REPL​

The node REPL ("Read Evaluate Print Loop") can be started by simply running node. This is both a great way to explore the language (e.g. verify what a given method returns) and explore installed / scoped modules. For the latter, you can type module from the REPL prompt to see the contents of the module object. Specically note the paths. If the module you want to create an instance of exists here you'll be able to create an instance of it, e.g. const moment = require('moment'). More detail here.

Handling Async​

At a console (Chrome or REPL) you'll be able to handle async / await via the following...

(async function(){ console.log(await x.list()) })();

Getting current module version number​

node -p "require('./package.json').version"

Libraries​

Utilities​

NVM - version manager​

"NVM allows you to quickly install and use different versions of node via the command line."

When using an .nvmrc file you can easily switch to the specified version by running nvm use at the root of the project.

NPX​

Run a command from a local or remote npm package.

E.g. npx kill-port 5000