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 './factoryWithThrowingShims' #134

Closed
collinksmith opened this issue Nov 20, 2017 · 9 comments
Closed

Cannot find module './factoryWithThrowingShims' #134

collinksmith opened this issue Nov 20, 2017 · 9 comments

Comments

@collinksmith
Copy link

Same error as #123, but clearing node_modules and installing from scratch did not resolve it.

My build process uses gulp and browserify. I get the same error for both prod and dev builds.

The first version in which I get this error is v2.0.0, and it is still present in v4.0.0. It looks like the line that throws the error was added in the commit to update webpack, and the missing file seems to be from prop-types.

Full error message:

Error: Cannot find module './factoryWithThrowingShims' from '/node_modules/react-responsive/dist'
    at /node_modules/browser-resolve/node_modules/resolve/lib/async.js:55:21
    at load (/node_modules/resolve/lib/async.js:69:43)
    at onex (/node_modules/resolve/lib/async.js:92:31)
    at /node_modules/resolve/lib/async.js:22:47
    at FSReqWrap.oncomplete (fs.js:82:15)
@yocontra
Copy link
Owner

Can you make a repo that reproduces the issue? Tried clearing npm cache?

@morokhovets
Copy link

Just added react-responsive to my project and can confirm the issue.
Clearing node_modules and npm cache does not resolve it.
Using 1.3.4 helps.

Also am using browserify (via browserify-rails) and babel (with 'es2015' and 'react' presets).

@yocontra
Copy link
Owner

yocontra commented Nov 21, 2017

Pushing up a maybe-fix as 4.0.1, give it a try and let me know if it works. Clear npm and cache then reinstall it.

Something to do with prop-types being bundled which would cause an issue on browserify, not 100% sure.

@yocontra yocontra reopened this Nov 21, 2017
@collinksmith
Copy link
Author

@contra Thanks. I wasn't able to try out your change because it doesn't seem to be available on npm, but I did make a simple repo that reproduces the error - https://github.com/collinksmith/react-responsive-test.

@yocontra
Copy link
Owner

@collinksmith Publish didn't finish - should be good now. 4.0.2

@collinksmith
Copy link
Author

Still getting the error in 4.0.2. There is no version 16.0.0 of prop-types, but I tried installing the latest version (15.6.0) and that didn't fix it.

@yocontra
Copy link
Owner

Ah, I found the issue. webpack only transforms code blocks that are accessed, there is a require('./factoryWithThrowingShims') in a if(false) - browserify must see this and still try to load it in as a dependency.

I would say both webpack and browserify are being stupid here. Anyways, I'll add something to minify out the dead code so browserify doesn't blow up on it.

@yocontra
Copy link
Owner

@collinksmith Published as 4.0.3

@collinksmith
Copy link
Author

Fix confirmed, thanks!

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

No branches or pull requests

3 participants