next.js: TypeError: Class constructor App cannot be invoked without 'new' after upgrade to next.js9
Bug report
TypeError: Class constructor App cannot be invoked without 'new'
Describe the bug
After upgrade to next.js9, my app can’t get compiled correctly, and here is the error message
TypeError: Class constructor App cannot be invoked without 'new'
at new MyApp (/Users/richard/tuya/developer-service-market/.next/server/static/development/pages/_app.js:8925:17)
at processChild (/Users/richard/tuya/developer-service-market/node_modules/react-dom/cjs/react-dom-server.node.development.js:2846:14)
at resolve (/Users/richard/tuya/developer-service-market/node_modules/react-dom/cjs/react-dom-server.node.development.js:2812:5)
at ReactDOMServerRenderer.render (/Users/richard/tuya/developer-service-market/node_modules/react-dom/cjs/react-dom-server.node.development.js:3202:22)
at ReactDOMServerRenderer.read (/Users/richard/tuya/developer-service-market/node_modules/react-dom/cjs/react-dom-server.node.development.js:3161:29)
at renderToString (/Users/richard/tuya/developer-service-market/node_modules/react-dom/cjs/react-dom-server.node.development.js:3646:27)
at render (/Users/richard/tuya/developer-service-market/node_modules/next-server/dist/server/render.js:81:16)
at renderPage (/Users/richard/tuya/developer-service-market/node_modules/next-server/dist/server/render.js:230:20)
at _callee$ (/Users/richard/tuya/developer-service-market/.next/server/static/development/pages/_document.js:261:22)
at tryCatch (/Users/richard/tuya/developer-service-market/node_modules/regenerator-runtime/runtime.js:45:40)
at Generator.invoke [as _invoke] (/Users/richard/tuya/developer-service-market/node_modules/regenerator-runtime/runtime.js:271:22)
at Generator.prototype.(anonymous function) [as next] (/Users/richard/tuya/developer-service-market/node_modules/regenerator-runtime/runtime.js:97:21)
at asyncGeneratorStep (/Users/richard/tuya/developer-service-market/node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator.js:5:24)
at _next (/Users/richard/tuya/developer-service-market/node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator.js:27:9)
at /Users/richard/tuya/developer-service-market/node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator.js:34:7
at new Promise (<anonymous>)
Expected behavior
My app get compiled correctly
System information
- OS: macOs latest
- Browser (if applies) chrome latest
- Version of Next.js: 9.0.0
Additional context
my .babelrc file
{
"presets": [
[
"next/babel",
{
"preset-env": {
"targets": {
"browsers": ["last 2 versions", "ie > 9"]
},
"corejs": "2",
"useBuiltIns": "usage",
"loose": true
},
"transform-runtime": {
"useESModules": false
}
}
]
],
"env": {
"development": {
"plugins": [
"react-intl"
]
},
"production": {
"plugins": [
["react-intl", {
"messagesDir": "lang/.messages/"
}]
]
}
},
"plugins": [
["lodash"],
[
"import",
{
"libraryName": "@tuya-fe/moon",
"libraryDirectory": "lib",
"style": "css"
}
],
["styled-components"]
],
"comments": false,
"compact": "auto"
}
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 4
- Comments: 17 (4 by maintainers)
It’s because of my wrong webpack external config, hope it’ll help @jacintorodrigues @AlanPieczonka
When I disabled/comment my config.module.rules.push in next.config.js and add target.node: ‘current’ in .baberc then the app run correctly. Check this comment 9000
@YUFENGWANG Could you tell what was causing the issue in next.config.js?
This is probably related to: https://github.com/zeit/next.js/issues/8175
compiled code in dev mode