Feb 2017 - whilst I agree with the accepted answer, wished to add a little more commentary here.
Like to setup as follows (from home directory on my Mac)
.node
├── node_modules
│ ├── lodash
│ └── ramda
├── package.json
└── repl.js
Then repl.js may look like as follows:
const repl = require('repl');
let r = repl.start({
ignoreUndefined: true,
replMode: repl.REPL_MODE_STRICT
});
r.context.lodash = require('lodash');
r.context.R = require('ramda');
// add your dependencies here as you wish..
And finally, put an alias into your .bashrc
or .zshrc
file etc (depending on your shell prefs) - something like:
alias noder='node ~/.node/repl.js'
Now, to use this configuration, you just have to type noder
from the command line. Above, I also specified that I'd always like to be in strict mode
, and do not want undefined
printed to the console for declarations etc.
For up-to-date information on repl
and in particular repl.start
options see here