O
O
Outsider V.2019-01-22 19:20:04
Node.js
Outsider V., 2019-01-22 19:20:04

How to access global context from REPL?

The idea is to initialize the main points in the js file, and then communicate with Node.js through the console - so that each time you do not do the same thing - rewrite the file and restart the node.
But here's the problem - the variables created in the file are not available in the console context:

'use strict';
const repl = require('repl');
let x = 1;
repl.start({});

> x
ReferenceError: x is not defined
>

How to make x available in interactive console?
Tried like this:
repl.start({
    useGlobal:true
});

no effect.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question