victorb / trymodule

➰ It's never been easier to try nodejs modules!
1.14k stars 29 forks source link

REPL cannot start due to error with loading history #33

Open lordlycastle opened 3 years ago

lordlycastle commented 3 years ago

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
lodash@4.17.21 .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.

kpman commented 3 years ago

@lordlycastle Which node version do you use?

lordlycastle commented 3 years ago

@kpman see below.

├── trymodule@1.4.0
❯ node --version && npm --version
v15.10.0
7.7.6
zeke commented 3 years ago

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
file-size@1.0.0 ../../../.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
jopemachine commented 2 years ago

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.