Search code examples
node.jsember.jsbrunch

Can't require('fs') in ember application


I'm having trouble adding the line require('fs') anywhere in ambari-web. I've tried adding it in ambari-web/app/app.js, ambari-web/app/controllers/wizard/step3_controller.js, and other places. Every time, I end up with

Uncaught Error: Cannot find module "fs" from "app"

or something similar in Chrome's console log. What is going wrong, what misunderstandings do I have, and how can I add the fs module to this ember application so that I can use it in a controller? I've tried running following all of the build instructions again after adding the module too -- without any luck.

Edit: is this a bad question? I'm getting downvoted, so let me know how to improve it.


Solution

  • fs is a Node.js module that is not available in browsers. There are various ways to emulate it in browsers, depending on what you're trying to do, but most likely to accomplish what you're attempting you'd need a separate Node.js program running that the web app makes requests to in order to trigger the file system operations you want to do.