question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Module not found: 'main/codecs' in '/lerna-monorepo/node_modules/json-url/src/main'

See original GitHub issue

I’m trying to use lerna to maintain multiple packages. One of my packages uses json-url npm module and when I tried to run my webpack bundle it gave me this error Module not found: 'main/codecs' in '/lerna-monorepo/node_modules/json-url/src/main'

the folder structure is lerna-monorepo –node_modules json-url –packages –mypackage <component-using-json-url>

I believe this is due to usage of absolute file referencing in json-url/src/main/index.js

Could you please help me out here

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
masotimecommented, Sep 24, 2020

Thanks for diving into this. My day job has been… busier than usual so it’s been hard to find the time to update the codebase which is admittedly out of date.

I can’t guarantee I’ll have time to work on this, but I’ll keep an eye out for PRs.

1reaction
bryanbrauncommented, Sep 24, 2020

I took a pass at updating the import paths in https://github.com/bryanbraun/json-url/commit/611564509c01288c3866d5408ff74400085303db and while that did make json-url itself es6 module compatible, I was still running into warnings saying that json-urls dependencies used node-specific features that would need to be polyfilled:

> npx snowpack@2.9.0

[snowpack] ! installing dependencies…
[snowpack] node_modules/msgpack5/index.js
   Import "assert" (Node.js built-in) is not available in the browser. Run with --polyfill-node to fix.
[snowpack] node_modules/lzma/index.js
   Import "path" (Node.js built-in) is not available in the browser. Run with --polyfill-node to fix.
[snowpack] node_modules/msgpack5/lib/decoder.js
   Import "util" (Node.js built-in) is not available in the browser. Run with --polyfill-node to fix.
[snowpack] node_modules/safe-buffer/index.js
   Import "buffer" (Node.js built-in) is not available in the browser. Run with --polyfill-node to fix.
[snowpack] node_modules/readable-stream/lib/_stream_readable.js
   Import "events" (Node.js built-in) is not available in the browser. Run with --polyfill-node to fix.
⋮

That makes me think that if we’re truly going to have a “module” entrypoint in package.json, then it’ll need to point to a module-specific build (perhaps /dist/module?) that has been compiled (and polyfilled), similar to the /dist/browser one.

It looks like Webpack has just added support for module builds in v5, so setting that up is probably the best route to getting this working.

The alternative is to revert https://github.com/masotime/json-url/commit/f7d69af322e5baac51a2bc090fb256a95ecb8811, so tools like webpack and snowpack will rely on the browser or node entrypoints instead (as a side-note, another workaround for this issue is to install "json-url": "2.4.0", which was the version before the module entrypoint was added. 😅 )

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: The specified module could not be found - Stack Overflow
I loaded edge_nativeclr.node in Dependency Walker and noticed that VCRUNTIME140.DLL , the Visual Studio 2015 C runtime, was missing. Edge.js ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found