Is there a way configure node.js’s repl? I want to require jquery and underscore automatically whenever the repl starts. Is there a file (noderc?) that node.js loads when it starts the repl?
The equivalent in Python is to edit ~/.ipython/ipy_user_conf.py with:
import_mod('sys os datetime re itertools functools')
I don’t know of any such configuration file, but if you want to have modules
fooandbarbe available in a REPL, you can create a filemyrepl.jscontaining:and you when you execute it with
node myrepl.jsyou get a REPL with those modules available.Armed with this knowledge you can put
#!/path/to/nodeat the top and make it executable directly, or you could modify your version of the repl.js module (source available at https://github.com/joyent/node/blob/master/lib/repl.js for inspection) or whatever 🙂