Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module on windows when using -r / -x #1511

Open
bvella opened this issue Mar 1, 2016 · 0 comments
Open

Cannot find module on windows when using -r / -x #1511

bvella opened this issue Mar 1, 2016 · 0 comments

Comments

@bvella
Copy link

bvella commented Mar 1, 2016

We are building an application that embeds plugins and we are using windows.

Plugins are separate js files built with:
browserify -x react -x ./common/react/Registry.js -d plugin1/Plugin1.js -o plugin1/bundle.js
where react and ./common/react/Registry.js are shared libraries, thus excluded from the plugins' bundle using the -x switch.

Main application is built with:
browserify -r react -r ./common/react/Registry.js -d app/app.js -o app/bundle.js
where react and ./common/react/Registry.js are made available for plugins using the -r switch

We are getting the following error when loading plugins:
Uncaught Error: Cannot find module '/common\react\Registry.js'

And have tracked it down to this line being generated in plugin's bundle.js:
...},{"../../../common/react/Registry":"/common\\react\\Registry.js","react":"react"}]},{},[1])
and when manually changed to:
...},{"../../../common/react/Registry":"/common/react/Registry.js","react":"react"}]},{},[1])
works fine. Seems that some parts of browserify use the unix style path separators but others use the OS path separators.

We have changed some lines in browserify index.js such that all paths use unix style path separators. We have added .replace(//g, '/') in all cases where path is used and it seems to have fixed the problem.

Should you require a test case, we would be happy to decompose the application down to a simple test case.

Attached is a diff of the index.js file.

index.js.diff.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant