Brunch global require conflicts with node local require
See original GitHub issueDescription
The bundle generated by brunch is not compatible with node’s environment, whenever I try to run the bundle in node for server rendering, I get something like:
TypeError: require.register is not a function
It is trying to use node’s require
, and not brunch’s.
Since in node require
is in the local context, so it takes precedence over brunch’s require, which is places in the global context.
Proposed solution
I think we could rename require
to __require__
in commonjs-require-definition/require.js and within the bundle.
We could still export both __require__
and require
to the global context.
Or we could remove commonjs-require-definition/require.js from its own scope, so at least inside the bundle it overrides node’s require (but this seems nasty).
I’m not sure if there is a better solution 😃
Environment
- Brunch: 2.8.2
- Node: v6.2.0
- NPM: 3.8.9
- Operating system: OS X El Capitan 10.11.6
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:22 (7 by maintainers)
Top Results From Across the Web
Brunch require with node.js modules - Stack Overflow
I have Brunch set up for ease of compiling JS together, but want to also be able to use a node.js module with...
Read more >Why the Hell Would I Use Node.js? A Case-by-case Tutorial
Node.js is a platform that fills a particular need, and understanding this is ... Installing packages locally prevents version conflicts at the global...
Read more >The Issue With Global Node Packages - Smashing Magazine
I'm specifically talking about installing packages from npm globally using npm install -g . Don't get me wrong: Installing packages globally ...
Read more >45 CFR Part 75 -- Uniform Administrative Requirements, Cost ...
Auditor means an auditor who is a public accountant, or a Federal, state, local government, or Indian Tribe audit organization, which meets the...
Read more >Babel · The compiler for next generation JavaScript - Babel.js
Not suitable for libraries. The require hook automatically hooks itself into all node requires. This will pollute the global scope and introduce conflicts....
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
@overallduka Great idea. I’ll give it a try and see what I come up with. Thanks!
@paulmedynski I think you miss-understood what @paulmillr is saying. Anyone can create a pull request (PR), you don’t have to be a maintainer. Once you successful create a PR, he will then be open to giving you commit access. Many projects operate this way to limit maintainer rights to those who have actually contributed to the project.