Questions tagged [node-repl]

The REPL provides a way to interactively run JavaScript and see the results. It can be used for debugging, testing, or just trying things out.

A Read-Eval-Print-Loop (REPL) is available both as a standalone program and easily includable in other programs. The REPL provides a way to interactively run JavaScript and see the results. It can be used for debugging, testing, or just trying things out.

By executing node without any arguments from the command-line you will be dropped into the REPL. It has simplistic emacs line-editing.

15 questions
69
votes
6 answers

How to write multiple lines of code in Node REPL

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?
aksanoble
  • 2,480
  • 4
  • 18
  • 19
4
votes
2 answers

Custom Node JS REPL input/output stream

I need to have custom REPL input/output stream. for example I need to pass a piece of script to the REPL when some event happens and get it's output and do something with it. To describe it more clear to you, I'm working on a vscode plugin (github:…
3
votes
1 answer

is it possible to debug node repl

Is is it possible debug NODE REPL. node cmd bring the repl prompt >. within the prompt is it possible to start the debugger. say for eg > hello = function(){ ....debugger; ....console.log('hello'); } >hello() --> should run in the debugger..
coool
  • 8,085
  • 12
  • 60
  • 80
2
votes
0 answers

Await in node repl (started using api)

One can run cli repl with await support like this: node --experimental-repl-await My question is: how do I do the same, but for repl, started from code using node api, similar to this: const repl = require('repl') repl.start('> ')
Eugene Loy
  • 12,224
  • 8
  • 53
  • 79
2
votes
2 answers

Getting data from fulfilled Q promise object in node REPL

Consider this simple Q promise object: nesh> var p = functionThatReturnsPromise(); The REPL is kind enough to output the promise's state and value if I go: nesh> p { state: 'fulfilled', value: { // (data properties) } } Suppose I…
Kludge
  • 2,653
  • 4
  • 20
  • 42
1
vote
1 answer

curl command hang on nginx server while uploading file thourgh stdin

First of all, I am trying to implement a repl server for my node.js application, I've created it with the help of this gist. everything is fine and I can connect to my repl server with this command in the localhost: $ curl -sSNT.…
mostafa8026
  • 273
  • 2
  • 12
  • 25
1
vote
1 answer

Using Node.js's REPL eval with an async function

I am using the Node.js REPL module to implement a REPL. Here's how I start the REPL: const cli = repl.start({ eval: evals }); I have a function, answer, that takes a few arguments and returns the answer. answer is async. evals is a function that…
1
vote
0 answers

How to save the return value from the query in Sails.js Console?

I am trying to run a simple query in my local Postgres db to return the User with an ID of 1 and save that value in the variable record. I'm using Sails.js and am in the Sails Console when I'm running these commands. I can get the query to print the…
Joseph Gill
  • 1,067
  • 11
  • 18
1
vote
1 answer

Disable this message - Expression assignment to _ now disabled? NodeJs-REPL

when I use var _ = require('underscore'), I got this message Expression assignment to _ now disabled.. Is there any way I can use to avoid this message? I can do change the variable name, but I found someone with the same node and the message did…
HeyLGT
  • 33
  • 5
1
vote
1 answer

Using the Node REPL to log the value of __dirname

If I write a script like containing console.log(__dirname); logs the value of __dirname. But if I try the same for the Node REPL like this happens: > console.log(__dirname) ReferenceError: __dirname is not defined Thoughts?
Ole
  • 41,793
  • 59
  • 191
  • 359
1
vote
1 answer

Differences between Node.js and Node.js REPL

I'm reading the "You don't know JS" book series and I tried to run the snippet: function foo() { console.log( this.a ); } function doFoo(fn) { // `fn` is just another reference to `foo` fn(); // <-- call-site! } var obj = { a: 2, foo:…
1
vote
0 answers

Node - how to stop undefined when module.exports.repl doesn't exist?

As indicated in node.js displays "undefined" on the console node will say undefined intentionally and is not usually an issue. The answer https://stackoverflow.com/a/18487887/631619 indicates that you can set module.exports.repl.ignoreUndefined =…
Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
0
votes
1 answer

Where is node repl default directory and how to change it?

I'm reloading my script a lot and would like to change the default directory where node repl is looking at so that I don't have to provide the whole path. Is that possible?
ditoslav
  • 4,563
  • 10
  • 47
  • 79
0
votes
1 answer

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

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…
CatDadCode
  • 58,507
  • 61
  • 212
  • 318
-1
votes
1 answer

What does comparing 2 Array mean in Javascript?

Inside my node.js REPL I create 4 arrays : a = [1,2,3], b=[], c=[4,5], d=null ( ok d is not an array but you get my point) I compare them directly this way : > b = [] [] > a > b true > b > a false > a > c false > c > a true > c > b true > b >…
Rohit Rane
  • 2,790
  • 6
  • 25
  • 41