How to resolve that `Cannot find module list.js` error?

Hi,

I’m using, in a js project, an npm package developped in ReScript.
And I end up with that error Cannot find module list.js. (the ReScript list module !!)
The only solution I found is to add ReScript as dependency to the project (in the package.json file).
But I’m looking for a way better solution: compiling the whole rescript library is not really acceptable…

Here is the full stacktrace:

Error: Cannot find module 'rescript/lib/js/list.js'
Require stack:
- /home/app/node_modules/@enspirit/dem-core-rescript/src/app.bs.js
- /home/app/node_modules/@enspirit/dem-fsi-rescript/src/fsi.bs.js
...
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:962:15)
    at Function.Module._load (internal/modules/cjs/loader.js:838:27)
    at Module.require (internal/modules/cjs/loader.js:1022:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/home/app/node_modules/@enspirit/dem-core-rescript/src/app.bs.js:4:12)
    at Module._compile (internal/modules/cjs/loader.js:1118:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
    at Module.load (internal/modules/cjs/loader.js:982:32)
    at Function.Module._load (internal/modules/cjs/loader.js:875:14)
    at Module.require (internal/modules/cjs/loader.js:1022:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/home/app/node_modules/@enspirit/dem-fsi-rescript/src/fsi.bs.js:5:11)
    at Module._compile (internal/modules/cjs/loader.js:1118:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
    at Module.load (internal/modules/cjs/loader.js:982:32)
    at Function.Module._load (internal/modules/cjs/loader.js:875:14)
    at Module.require (internal/modules/cjs/loader.js:1022:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/home/app/lib/utils/dem.js:1:13)
    at Module._compile (internal/modules/cjs/loader.js:1118:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
    at Module.load (internal/modules/cjs/loader.js:982:32) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/app/node_modules/@enspirit/dem-core-rescript/src/app.bs.js',
    '/home/app/node_modules/@enspirit/dem-fsi-rescript/src/fsi.bs.js',
    ...
  ]
}

Does anyone have an idea why I get that error ?

It’s the right solution, rescript should be listed in the package.json dependencies.

But I’m looking for a way better solution: compiling the whole rescript library is not really acceptable

What exactly are you concerned of?

Well, I was (probably misleading) concerned of the size, and compiling time, of that library.
But if that’s the right solution, then great !

The bundle size is not a problem, because you only import js utility code. Moreover, it’s well tree-shakeable.