--node doesn't work
See original GitHub issueI am using browserify v13.0.0
I have an a.js
which just has a module.exports = {a: 1}
And I run browserify as so:
browserify --node --debug a.js > bundle.js
In the node REPL,
> require ('./bundle.js')
{}
>
Why the {}
? Shouldn’t it give me {a: 1}
?
Although I’ve reduced my problem to the simplest case, this behavior is stopping me from bundling a project involving multiple coffeescript files into a single file for node & browsers.
Ive also tried --bare
, --no-builtins
, --no-bf
Issue Analytics
- State:
- Created 8 years ago
- Comments:6
Top Results From Across the Web
Node js doesn't work in a terminal ...
So I installed it and it was successful but just in that terminal! If I type node -v or npm -v it shows...
Read more >'Node' Is Not Recognized As An Internal Or External ...
'node' is not recognized as an internal or external command, operable program or batch file ❓ [How to Solve] · Open Control Panel...
Read more >NodeJS is not recognizing commands on windows 10
1 Answer 1 · Go to start and search for Node.js [ a 'desktop app' should appear with a green icon having the...
Read more >Troubleshoot your Node.js installation
If you have encountered any of these common problems after installing your New Relic Node.js agent, try these troubleshooting tips.
Read more >How to resolve 'node' is not recognized as an internal ...
Open the Environment Variables option in your Control Panel. · Select the variable named Path. · Restart the command prompt again and now...
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
This isn’t an issue with
--node
, this is just how browserify works. When you dobrowserify a.js
you generate a bundle that will runa.js
, not export the functionality ofa.js
. You should use--require
or--standalone
to generate bundles that will export functionality instead of running when executed.@substack Using
-s foo
works, but this will generate a global when loaded into a commonjs environment (which in general is not bad).--require
does not work. It still exports an empty object, like--node
does.Basically, the best one is
-s foo
but I don’t want to create a global at all, because I know that I will load the module in a Node.js environment. So, what is the option to export functionality but not include the check for commonjs existence?Thanks! 🍰