rsify / jay

😎 Supercharged JavaScript REPL
MIT License
984 stars 19 forks source link

Requiring built-in modules throws an error #14

Open chrissantamaria opened 5 years ago

chrissantamaria commented 5 years ago

Not sure if I'm missing something here - requiring standard NPM modules works as expected (such as const axios = require('axios')) but any built-in module such as fs or querystring fails:

node v12.4.0 npm@6.9.0 jay-repl@0.2.1
Type `> jay.help()` in the prompt for more information.
> const fs = require('fs')
C:\Users\Chris\AppData\Local\Yarn\Data\global\node_modules\jay-repl\dist\moduler.js:158
            throw new Error(`\`${id}\` has an invalid \`package.json\` file`);
            ^

Error: `fs` has an invalid `package.json` file
    at C:\Users\Chris\AppData\Local\Yarn\Data\global\node_modules\jay-repl\dist\moduler.js:158:19
    at Left.getOrElseL (C:\Users\Chris\AppData\Local\Yarn\Data\global\node_modules\fp-ts\lib\Either.js:127:16)
    at decodePkg (C:\Users\Chris\AppData\Local\Yarn\Data\global\node_modules\jay-repl\dist\moduler.js:157:13)
    at _resolve (C:\Users\Chris\AppData\Local\Yarn\Data\global\node_modules\jay-repl\dist\moduler.js:180:21)
    at _require (C:\Users\Chris\AppData\Local\Yarn\Data\global\node_modules\jay-repl\dist\moduler.js:191:39)
    at evalmachine.<anonymous>:1:12
    at Script.runInContext (vm.js:134:20)
    at Object.<anonymous> (C:\Users\Chris\AppData\Local\Yarn\Data\global\node_modules\jay-repl\dist\eval.js:94:41)
    at Generator.next (<anonymous>)
    at C:\Users\Chris\AppData\Local\Yarn\Data\global\node_modules\jay-repl\dist\eval.js:7:71
>

I'm on Windows 10 and installed jay globally with Yarn.

rsify commented 5 years ago

definitely shouldn't be happening, thanks.

fyi - just like in the vanilla node repl - all built-in modules are available by default, there's no need to require them.

talentlessguy commented 5 years ago

having the same issue

image