node-repl

How do I limit the node repl's access to internal node modules?

半城伤御伤魂 提交于 2020-01-06 08:09:31
问题 In a previous question I figured out how to eliminate unwanted global variables from the repl context. However, I figured out that the repl automatically has access to ALL internal node modules without the use of require . I have no idea how to disable this. I even tried overriding the module variables in the repl itself and it doesn't work. > fs = "test"; > fs It still displays fs original value. This is very unfortunate because I'm trying to expose a public repl but it gives them access to

How to write multiple lines of code in Node REPL

孤者浪人 提交于 2019-11-28 20:51:02
问题 I would like to evaluate var foo = "foo"; console.log(foo); as a block, instead of evaluating line by line var foo = "foo"; undefined console.log(foo); foo undefined Is there a simple way to move the prompt to the next line? 回答1: Node v6.4 has an editor mode. At the repl prompt type .editor and you can input multiple lines. example $ node > .editor // Entering editor mode (^D to finish, ^C to cancel) const fn = there => `why hello ${there}`; fn('multiline'); // hit ^D 'why hello multiline' >