stackblitz / webcontainer-core

Dev environments. In your web app.
https://webcontainers.io
MIT License
3.77k stars 142 forks source link

Internal server error for Next.js #796

Closed Nefcanto closed 1 year ago

Nefcanto commented 2 years ago

Describe the bug

A lot of times when I try to create a next.js app, as I change files and package.json I encounter Internal Server Error.

Here's a log:

success Install finished in 1.443s
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - Disabled SWC as replacement for Babel because of custom Babel configuration ".babelrc" https://nextjs.org/docs/messages/swc-disabled
info  - Using external babel configuration from /home/projects/nextjs-9zbx4x/.babelrc
error - ./node_modules/next/dist/client/dev/amp-dev.js
Error: [BABEL] /home/projects/nextjs-9zbx4x/node_modules/next/dist/client/dev/amp-dev.js: Cannot find module 'babel-plugin-macros'
Require stack:
- /home/projects/nextjs-9zbx4x/node_modules/styled-jsx/dist/babel/index.js
- /home/projects/nextjs-9zbx4x/node_modules/styled-jsx/babel.js
- /home/projects/nextjs-9zbx4x/node_modules/next/dist/build/babel/preset.js
- /home/projects/nextjs-9zbx4x/node_modules/next/babel.js
- /home/projects/nextjs-9zbx4x/node_modules/next/dist/compiled/babel/bundle.js
- /home/projects/nextjs-9zbx4x/node_modules/next/dist/compiled/babel/traverse.js
- /home/projects/nextjs-9zbx4x/node_modules/next/dist/build/babel/loader/transform.js
- /home/projects/nextjs-9zbx4x/node_modules/next/dist/build/babel/loader/index.js
- /home/projects/nextjs-9zbx4x/node_modules/next/dist/compiled/webpack/bundle5.js
- /home/projects/nextjs-9zbx4x/node_modules/next/dist/compiled/webpack/webpack.js
- /home/projects/nextjs-9zbx4x/node_modules/next/dist/server/config-utils.js
- /home/projects/nextjs-9zbx4x/node_modules/next/dist/server/config.js
- /home/projects/nextjs-9zbx4x/node_modules/next/dist/server/next.js
- /home/projects/nextjs-9zbx4x/node_modules/next/dist/server/lib/start-server.js
- /home/projects/nextjs-9zbx4x/node_modules/next/dist/cli/next-dev.js
- /home/projects/nextjs-9zbx4x/node_modules/next/dist/lib/commands.js
- /home/projects/nextjs-9zbx4x/node_modules/next/dist/bin/next (While processing: "/home/projects/nextjs-9zbx4x/node_modules/next/babel.js")
info  - Downloading WASM swc package...
ERR!: Unknown command `config`

From this fork

What should I do to fix it?

Link to the blitz that caused the error

https://stackblitz.com/edit/nextjs-9zbx4x?file=cache.js

Steps to reproduce

I can't tell when it happens. It just happens. No specific pattern exists. Just add a couple of packages and change files.

Expected behavior

It should work fine. Or at least it should let us fix it. The least possible thing is to let us know how to solve it.

Parity with Local

Screenshots

No response

Platform

Browser name  = Chrome
Full version  = 105.0.0.0
Major version = 105
navigator.appName = Netscape
navigator.userAgent = Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36
performance.memory = {
  "totalJSHeapSize": 105100054,
  "usedJSHeapSize": 100725210,
  "jsHeapSizeLimit": 2172649472
}
Hash = 2920c879366045e9300c0e5685ed32a2f19795be

Additional context

No response

d3lm commented 1 year ago

It looks like not all dependencies were installed. Note that turbo does not automatically install peer dependencies, so if babel-plugin-macros happens to be a peer dependency then you must add this to your list of dependencies.

d3lm commented 1 year ago

Any updates? Did you try to install missing peer dependencies? If you're still seeing this error even if all dependencies have been installed, could you please provide more info? Note that, yarn as well as pnpm don't install peer dependencies, although pnpm changed that behavior recently.

Nefcanto commented 1 year ago

We somehow managed to solve it. I don't remember how though. Thank you.