preact-x with compat with nextjs. Cannot find module 'preact/compat/server'
See original GitHub issueHi All,
Very excited to try out the latest preact as a compat with Next.js .
Sandbox link :- https://codesandbox.io/s/823konwnw8?fontsize=14
Used module alias to integrate ;-
const moduleAlias = require('module-alias')
module.exports = () => {
moduleAlias.addAlias('react', 'preact/compat')
moduleAlias.addAlias('react-dom', 'preact/compat')
}
Here is the output error I am getting :-
$ node server.js
internal/modules/cjs/loader.js:605
throw err;
^
Error: Cannot find module 'preact/compat/server'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
at Function.Module._resolveFilename (/Users/maruti/projects/test-nextjs/node_modules/module-alias/index.js:43:29)
at Function.Module._load (internal/modules/cjs/loader.js:529:25)
at Module.require (internal/modules/cjs/loader.js:658:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/Users/maruti/projects/test-nextjs/node_modules/next-server/dist/server/render.js:14:18)
at Module._compile (internal/modules/cjs/loader.js:722:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
preact-x with compat with nextjs. Cannot find module ... - GitHub
The error is happening beause next.js is importing "react-dom/server" and it is not able to find it.
Read more >Switching to Preact (from React)
The preact-compat package provides all the necessary tweaks on top of Preact's core to make it work just like react and react-dom ,...
Read more >Use Preact in Next.js 13 - DEV Community
Preact has the fastest Virtual DOM compared to other JavaScript frameworks. It is small in size. Tiny! It is designed to work in...
Read more >Cannot find module 'react' when use third party React UI lib
You'll want to run the following: yarn add react@npm:@preact/compat react-dom@npm:@preact/compat. Seems like Vitest cannot effectively ...
Read more >react-hot-loader - npm
webpack.config.js module.exports = { entry: ['react-hot-loader/patch', '. ... React-hot-loader should work out of the box with preact-compat ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Good catch!
server.js
wasn’t listed in the files Preact includes when publishing to npm. Fix will go out shortly.@developit that stopped working for me in 10.x, I’m opening another issue with repro 😃