2

In reference to this question (browserify 'Error: Cannot find module' in trying to fix 'Uncaught reference error: require is not defined'), I got the browserify command to work thanks to stackoverflow community, however, I got another error that tells me

Uncaught TypeError: undefined is not a function bundle.js:10786
Mime.load bundle.js:10786
(anonymous function) bundle.js:10822
_process bundle.js:10848

I believe the function it is complaining about is the 'fs.readFileSync' function. Here is the line 10786 in my 'bundle.js' file

Mime.prototype.load = function(file) {

  this._loading = file;
  // Read file and split into lines
  var map = {},
      content = fs.readFileSync(file, 'ascii'), <---LINE 10786
      lines = content.split(/[\r\n]+/);

  lines.forEach(function(line) {
    // Clean up whitespace/comments, and split into fields
    var fields = line.replace(/\s*#.*|^\s*|\s*$/g, '').split(/\s+/);
    map[fields.shift()] = fields;
  });

  this.define(map);

  this._loading = null;
};
3
  • Pro-tip: passing the -d or --debug flag to browserify will enable source maps, this makes it a lot easier to determine where errors occur in your code. Commented Jul 28, 2014 at 15:52
  • Hey Mike, should I call it like 'browserify app/index.js > app/bundle.js -d' or just 'browserify -d' Commented Jul 28, 2014 at 15:53
  • More like browserify -d app/index.js > app/bundle.js Commented Jul 28, 2014 at 15:55

1 Answer 1

3

In general, you cannot access the file system using Browserify since there's no file system for it to access (remember, you're running this on the web, not just your computer).

However, you can inline the contents of files using the brfs module.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.