Non browser compatible node-module required
See original GitHub issueFor reasons too long to explain here, I can’t include browser compatible polyfills for built-in nodejs modules.
So when I’m compiling targeting the browser with rollup I’m getting
[!] Error: Could not load util (imported by node_modules/stacktracey/stacktracey.js): ENOENT: no such file or directory, open 'util'
Error: Could not load util (imported by node_modules/stacktracey/stacktracey.js): ENOENT: no such file or directory, open 'util'
perhaps some easy isBrowser
will fix this. I’m also sure that it should be possible to find require ('util').inspect
browserified (using built-in modules if in nodejs env).
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Publishing packages that can be used in browsers and Node
If you want to create a package that's usable in both browsers and Node, this article is here to help.
Read more >CommonJS modules | Node.js v19.3.0 Documentation
CommonJS modules are the original way to package JavaScript code for Node.js. Node.js also supports the ECMAScript modules standard used by browsers and ......
Read more >How to write modules that are both nodejs compatible and ...
I am writing a node module {collection of modules}and in future this might be ported to browser environments too. For that reason I...
Read more >Use this One-Liner to Make any Node.js Module Run in a Web ...
You can convert a node module to its web-browser-compatible version with this single shell command: (Of course, you need to have myNodeModule already ......
Read more >browserify/browserify: browser-side require() the node.js way
compatibility. Many npm modules that don't do IO will just work after being browserified. Others take more work. Many node built-in modules ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So I tested the changes, I got the exact same error
to be sure it’s new version, I looked into node_modules at the package.json version
"version": "1.1.164",
So I just made a reproduceable example repo which actually starts with a different error message, as I’ve already made a browserify global alias for nodejs’s path module (this I can’t do with all modules as I have dependencies which require their own fs and util for example).
This you can test out here https://github.com/hlolli/ololog_bug using the command
yarn build
. The two plugins (which are potentially the culprits) are @rollup/plugin-node-resolve for putting the node_modules into scope, and @rollup/plugin-commonjs for importing commonjs modules as es module.Thank you for the repro, I’ll look into it in the coming days.