trymodule icon indicating copy to clipboard operation
trymodule copied to clipboard

REPL cannot start due to error with loading history

Open lordlycastle opened this issue 3 years ago • 4 comments

I get this error when I try to run anything e.g. trymodule lodash:

Gonna start a REPL with packages installed and loaded for you
Couldn't find 'lodash' locally, gonna download it now
[email protected] .trymodule/node_modules/lodash
Package 'lodash' was loaded and assigned to 'l' in the current scope
REPL started...
  /usr/local/lib/node_modules/trymodule/node_modules/repl.history/index.js:19
  repl.rli.addListener('line', function(code) {
           ^

TypeError: Cannot read property 'addListener' of undefined
    at module.exports (/usr/local/lib/node_modules/trymodule/node_modules/repl.history/index.js:19:12)
    at /usr/local/lib/node_modules/trymodule/cli.js:72:7
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)

I've done basic clean up steps i.e. uninstall trymodule and delete the ~/.trymodule/ folder (or trymodule --clear).

I don't understand why it fails here.

lordlycastle avatar Mar 31 '21 12:03 lordlycastle

@lordlycastle Which node version do you use?

kpman avatar Apr 12 '21 02:04 kpman

@kpman see below.

├── [email protected]
❯ node --version && npm --version
v15.10.0
7.7.6

lordlycastle avatar Apr 15 '21 15:04 lordlycastle

I just ran into this. :[

$ trymodule file-size
Gonna start a REPL with packages installed and loaded for you
Couldn't find 'file-size' locally, gonna download it now
[email protected] ../../../.trymodule/node_modules/file-size
Package 'file-size' was loaded and assigned to 'file_size' in the current scope
REPL started...
  /Users/z/.npm-global/lib/node_modules/trymodule/node_modules/repl.history/index.js:19
  repl.rli.addListener('line', function(code) {
           ^

TypeError: Cannot read properties of undefined (reading 'addListener')
    at module.exports (/Users/z/.npm-global/lib/node_modules/trymodule/node_modules/repl.history/index.js:19:12)
    at /Users/z/.npm-global/lib/node_modules/trymodule/cli.js:72:7
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

~/git/replicate/replicate-web main*
$ node --version
v16.9.0

zeke avatar Sep 20 '21 21:09 zeke

This issue is related with repl.history which is used in this module.

The node's repl API (REPLServer.rli) changed after Node 16.

The repl.rli.addListener should be replaced with repl.addListener.

jopemachine avatar Nov 24 '21 11:11 jopemachine