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.

--node doesn't work

See original GitHub issue

I 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:closed
  • Created 8 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
ghostcommented, Feb 21, 2016

This isn’t an issue with --node, this is just how browserify works. When you do browserify a.js you generate a bundle that will run a.js, not export the functionality of a.js. You should use --require or --standalone to generate bundles that will export functionality instead of running when executed.

0reactions
IonicaBizaucommented, Feb 21, 2016

@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! 🍰

Read more comments on GitHub >

github_iconTop 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 >

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