7

I have this file (a large bundle of a couple of JS files) that used to work with browserify (5.10.0 ) till a couple of days ago, and now it does not.

This is what I am running:

$ browserify index.js -o dist/out.bundle.js

And the output is:

Error: path must be a string
at /usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:15:16
at process._tickCallback (node.js:419:13)

Anyone knows what might cause this? Is there a way I can debug this to try and figure out what bothers browserify?

Cheers

3 Answers 3

4

maybe there is something wrong in your package.json config, especially take care for the line transform!~

"browserify": {
    "transform": [
        [
            "reactify", {
                "harmony": "true"
            }
        ]
    ]
  }
0
2

Sadly the error message is not very helpful, but what's happening is this:

Browserify uses the resolve module to look up the files require calls should be loading. Somehow instead of being passed a path as normally, it got something else (i.e. not a string).

This could theoretically be almost anything, but I'm guessing it's either undefined or some really absurd value like an object or function. Basically anything that could theoretically be passed to require and result in garbage.

You didn't say whether you updated modules, added new transforms or modified any code in the meantime. As you imply that this worked with exactly the browserify version you are using now, I'm going to go out on a limb and guess it's either a transform misfiring or a mistake in your code.

Try finding all the require calls in code you recently modified (since the last known good version). If you use source control (who am I kidding: I'm thinking of git) this should be fairly trivial. If you're not using source control, you should be using source control.

If you're finding any new require calls that pass something other than a string to require (e.g. multiple arguments or even variables), you may have found your culprit.

If that didn't help, see if you have any transforms that may end up in require calls being modified. This could be nearly everything.

If that didn't do any good either, try updating everything to the latest version. Besides possibly causing problems if you use really outdated versions of anything, it may fix your problem. Try updating to the latest minor release (for versions >= 1.0) or bugfix release (for versions < 1.0) if you want to avoid compatibility problems.

If that still doesn't help, please post more details and make sure you understand the exact differences between the code that worked "a couple of days ago" and the code you have now.

0

You may have forgotten to install transform package with npm. For example if you are using babelify transform with browserify you may forget to install babelify.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.