ERROR in ./node_modules/.registry.npmjs.org/react-apollo/2.1.0-beta.0/node_modules/react-apollo/renderToStringWithData.js
Module not found: Error: Can't resolve 'react-dom/server' in '/Users/Vaughan/dev-live/vwp/node_modules/.registry.npmjs.org/react-apollo/2.1.0-beta.0/node_modules/react-apollo'
@ ./node_modules/.registry.npmjs.org/react-apollo/2.1.0-beta.0/node_modules/react-apollo/renderToStringWithData.js 3:15-42
@ ./node_modules/.registry.npmjs.org/react-apollo/2.1.0-beta.0/node_modules/react-apollo/index.js
@ ./packages/next-apollo/withData.js
@ ./pages/map.js
@ multi ./pages/map.js
This aliasing seems to prevent require sub-paths.
PS. I am using pnpm. Maybe this could be related...
Workaround
Add this to your next.config.js:
delete config.resolve.alias['react-dom']
| Tech | Version |
|---------|---------|
| next | 5 |
| node | 8 |
| OS | macOS |
| browser | Chrome |
| etc | |
i am also having issues with react-dom/server not being found after i upgraded as well as other random issues that were not occurring before :
i want to upgrade my next 4 project but things are breaking in a weird way (erratically… sometimes it works sometimes it doesnt)
for example, im using hot reloading for and changing a css file now throws: Module build failed: Error: ENOENT: no such file or directory, open /path/to/file.css.json. i've been using a file loader in next.config.js to transform css before passing to postcss. this stopped working now in version 5 :
I am also having same issue /cc @arunoda
It have in this live stream https://www.youtube.com/watch?v=yCDLVpyQ5NI
Got it working using that delete work around
@pantharshit00 @vjpr
I can see why this is happening.
I'll have a look.
@vjpr could you check with bundle-analyzer and see react-dom/server used in the client side or not.
If so, try to remove it with our custom webpack config.
@arunoda This fixes this in our project.
https://github.com/fus-marcom/franciscan-react/blob/next5/next.config.js
Here is our babel plugin module resolver
@pantharshit00 thanks for the input.
We didn't realized react-dom/server is gonna used inside the client.
We may want to add an alias for that.
(For the production build, we use React's minified production bundle)
I had the same issue. Made it work with using this:
// working
import { server } from 'react-dom';
server.renderToString(<Component />);
instead of:
// not working
import { renderToString } from 'react-dom/server';
renderToString(<Component />);
Edit:
Which doesn't work on next export
Hey, this fix exists in https://github.com/zeit/next.js/releases/tag/5.0.1-canary.2
It took me a while to figure it out, so in case anyone as has the same problem doing delete config.resolve.alias['react-dom'] will break the dead code compilation of your production build but the fix from @arunoda in 5.0.1-canary.2 provides a proper fix without the breaking the compilation.
Most helpful comment
Hey, this fix exists in https://github.com/zeit/next.js/releases/tag/5.0.1-canary.2