I'd like to distribute my node.js app as a single js file. The application is really simple, but it depends on a few libraries.
Browserify seems to bundle the npm
dependencies nicely. However the app also depends on the fs
built-in file system library and unfortunately its signatures doesn't seem to be loaded. For instance the following code gives undefined is not a function
error.
var fs = require('fs')
fs.readFileSync(file, 'utf8');
I understand that main purpose of Browserify is to bring CommonJs based apps to the browser. But I wonder if there is any way to make the compiler fall back to the default require
global function for built-in libraries.
After going through all options it turned out that the --bare
switch satisfies my requirement.
browserify --bare
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With