ef4 / ember-browserify

ember-cli addon for easily loading CommonJS packages from npm via browserify.
MIT License
172 stars 28 forks source link

Can't require Node.js core modules #59

Closed barisnisanci closed 8 years ago

barisnisanci commented 8 years ago

Can't use any npm package that requires nodejs core modules like require('fs'). Gives this error: Uncaught Error: Could not find module fs Am I missing something or is there a way to use nodejs core modules?

asakusuma commented 8 years ago

You can only import modules that are directly available from the projects node_modules folder, which means you can't import core node modules. In other words, you can only import modules declared in package.json.

You could try finding a file operation library for the browser and import that.

barisnisanci commented 8 years ago

Problem is nodejs fs is like a base component that every filesystem package expands it. Rewrting that module would be unnecessary. It would be better to be able to reach that.

asakusuma commented 8 years ago

Node's fs library is specifically written for a server. What the browser can do with the filesystem is fundamentally different and far more limited than what you can do on the server. That being said, someone has already done a port of fs for the browser. You could try using that and then remap the module id using the browserify configs.

Anyways, ember-browserify is just a wrapper around browserify, we can try and support whatever browserify supports, but we have no plans to go beyond that.

Edit: Grammar