question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

preact-x with compat with nextjs. Cannot find module 'preact/compat/server'

See original GitHub issue

Hi 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:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
developitcommented, Mar 5, 2019

Good catch! server.js wasn’t listed in the files Preact includes when publishing to npm. Fix will go out shortly.

0reactions
damianobarbaticommented, Mar 5, 2019

@developit that stopped working for me in 10.x, I’m opening another issue with repro 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found