developit / nextjs-preact-demo

Next.js 9.3 + Preact = 21kB
https://nextjs-preact.now.sh
384 stars 25 forks source link

Broken with Next 9.3.0 #5

Closed sinisterstumble closed 4 years ago

sinisterstumble commented 4 years ago

Error: Package exports for '/Users/l5x/devel/nextjs-preact-demo/node_modules/preact' do not define a valid './compat' target
    at resolveExportsTarget (internal/modules/cjs/loader.js:621:9)
    at applyExports (internal/modules/cjs/loader.js:502:14)
    at resolveExports (internal/modules/cjs/loader.js:551:12)
    at Function.Module._findPath (internal/modules/cjs/loader.js:657:22)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:960:27)
    at Function.Module._load (internal/modules/cjs/loader.js:855:27)
    at Module.require (internal/modules/cjs/loader.js:1033:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/Users/l5x/devel/nextjs-preact-demo/node_modules/react/index.js:1:18)
    at Module._compile (internal/modules/cjs/loader.js:1144:30) {
  code: 'MODULE_NOT_FOUND'
}
developit commented 4 years ago

Hi there - any chance you're using an older version of npm? This repo requires npm 6.

pronevich commented 4 years ago

npm 6.13.4 same issue

m5r commented 4 years ago

No issue with node 13.11.0 and npm 6.13.7

sinisterstumble commented 4 years ago

Interesting ;) Broken for me with

~/nextjs-preact-demo $ npm -v                                                                                                                                                     ¡
6.14.3
~/nextjs-preact-demo $ node -v
v13.6.0
developit commented 4 years ago

Can you also provide the version of Preact you have installed locally? (npm ls preact) I'm seeing valid export maps for ./compat, not sure what else could be going wrong here.

sinisterstumble commented 4 years ago

I have no idea what changed but its building correctly now. Did same exact steps:

git clone https://github.com/developit/nextjs-preact-demo.git
cd nextjs-preact-demo
npm i
npm run build
~/d/nextjs-preact-demo $ npm -v
6.14.3
~/d/nextjs-preact-demo $ node -v
v13.6.0
~/d/nextjs-preact-demo $ npm ls preact
nextjs-preact-demo@1.0.0 /Users/l5x/devel/nextjs-preact-demo
└── preact@10.2.1
sinisterstumble commented 4 years ago

Ignore the previous message. I forgot to upgrade next. This is the steps:

git clone https://github.com/developit/nextjs-preact-demo.git
cd nextjs-preact-demo
ncu -u
npm i
npm run build
~/d/nextjs-preact-demo $ npm ls preact
nextjs-preact-demo@1.0.0 /Users/l5x/devel/nextjs-preact-demo
└── preact@10.3.4
~/d/nextjs-preact-demo $ npm ls next
nextjs-preact-demo@1.0.0 /Users/l5x/devel/nextjs-preact-demo
└── next@9.3.1
developit commented 4 years ago

I just opened a PR with the dep upgrades (#6), and testing on Gitpod I can't reproduce:

$ node -v
v13.11.0

$ npm -v
6.13.7

$ npm ls --depth 0
nextjs-preact-demo@1.0.0 /workspace/nextjs-preact-demo
├── next@9.3.1
├── preact@10.3.4
├── preact-render-to-string@5.1.4
├── UNMET PEER DEPENDENCY react@1.0.0 (github:preact-compat/react#acfe2cc2acc677d08fb8edf8ce04796634d8edf8)
├── UNMET PEER DEPENDENCY react-dom@1.0.0 (github:preact-compat/react-dom#75804a834f55de5350c175f9646631dabac258ae)
└── react-ssr-prepass@npm:preact-ssr-prepass@1.0.1

npm ERR! peer dep missing: react@^16.6.0, required by next@9.3.1
npm ERR! peer dep missing: react-dom@^16.6.0, required by next@9.3.1
npm ERR! peer dep missing: react@15.x.x || 16.x.x, required by styled-jsx@3.2.5
npm ERR! peer dep missing: react@^16.8.0, required by use-subscription@1.1.1

@l5x my guess is that you're using npm-check-updates to perform the update, which does not support npm aliases. That means when you run ncu -u, you're installing React instead of Preact.

I've just merged the 9.3.1 update to master. If you pull from master and do a fresh npm install I'm confident it will work for you.

developit commented 4 years ago

I'm going to close this out since I think ncu is the culprit and that's just their bug. Let me know if it's still an issue with the above process and we can re-open.

sinisterstumble commented 4 years ago

No issue in a clean centos/8 vagrant box. But still failing locally on macos.

@developit thank you!

I will reinstall nvm/node and report back with results, may help @pronevich.