preactjs / preact-compat

ATTENTION: The React compatibility layer for Preact has moved to the main preact repo.
http://npm.im/preact-compat
MIT License
950 stars 148 forks source link

Can't resolve 'react' #533

Closed andrevenancio closed 4 years ago

andrevenancio commented 4 years ago

I have an application running Preact, I'm importing snap-state module (which depends on React).

I get this error Module not found: Error: Can't resolve 'react' in '/Users/XXX/YYYY/node_modules/snap-state/dist'

I've added the aliases to the webpack configuration as per the instructions on github... any way of testing what's wrong?

marvinhagemeister commented 4 years ago

Can you share a repo or a codesandbox where the issue can be reproduced? It sounds very much like the aliasing isn't done correctly. Also note that preact-compat only works with Preact 8.x. For Preact X you must use preact/compat instead which ships in the preact package itself.

andrevenancio commented 4 years ago

You're right. In my case I had 2 webpack builds running one for DLL and another for my app. I only added the alias to the app not the DLL and my imports were on the DLL. so silly me. Also, giving Preact X a go cause I need hooks :) thanks!