"Error: the path must be a string" (v5.10.0)

I have this file (a large package of several JS files) that was used to work with the browser (5.10.0) up to two days ago, and now it is not.

This is what I run:

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

And the result:

 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) 

Does anyone know what might cause this? Is there a way to debug this to try to figure out what the browser is bothering with?

Greetings

+7
javascript browserify
source share
3 answers

maybe something is wrong in your package.json configuration, especially take care of the string conversion! ~

 "browserify": { "transform": [ [ "reactify", { "harmony": "true" } ] ] } 
+4
source share

Unfortunately, the error message is not very useful, but what happens:

Browserify uses the resolve module to search for files. require should load calls. Somehow, instead of traversing the path as usual, he got something else (i.e. Not a string).

Theoretically, it can be almost anything, but I assume that it is either undefined or some really absurd value, like an object or function. In principle, anything that could theoretically be passed to require and result in garbage.

You did not say whether you updated the modules, added new transformations or modified any code during this time. Since you mean that it worked exactly with the version of the browser that you are using now, I'm going to go on a limb and guess this is either a broadcast skip or an error in your code.

Try to find all the calls to require in the code you recently changed (starting with the last known good version). If you use source control (who I'm joking about: I'm thinking of git), this should be pretty trivial. If you are not using a control source, you must use a control source.

If you discover new calls to require that pass something other than a string to require (for example, a few arguments or even variables), you may have found your culprit.

If this does not help, see if you have any conversions that might appear in require called calls. It could be just about everything.

If this also does not help, try updating everything to the latest version. Besides possible problems, if you use really outdated versions of something, this can solve your problem. Try upgrading to the latest version (for versions> = 1.0) or the fix release (for versions 1.0) if you want to avoid compatibility issues.

If this still does not help, write more detailed information and make sure that you understand the exact differences between the code that worked "a couple of days ago" and the code that you have.

+2
source share

You may have forgotten to install the conversion package with npm number. For example, if you use the babelify transform using a browser, you may forget to install babelify.

0
source share

All Articles