Start up script for node.js repl

前端 未结 5 657
醉酒成梦
醉酒成梦 2020-12-30 02:01

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 i

5条回答
  •  心在旅途
    2020-12-30 02:43

    Keeping things simple here's what I clabbered up.

    repl.js:

    // things i want in repl
    global.reload = require('require-nocache')(module) // so I can reload modules as I edit them
    global.r = require('ramda') // <3 http://ramdajs.com/
    // launch, also capture ref to the repl, in case i want it later
    global.repl = require('repl').start()
    

    I can invoke this with node repl which feels right, and I don't care about globals, because I am just messin' around in the repl.

提交回复
热议问题