Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"TypeError: Object(...) is not a function" with create-next-app and next dev #22206

Closed
armordecai opened this issue Feb 16, 2021 · 7 comments
Closed
Labels
bug Issue was opened via the bug report template. please add a complete reproduction Please add a complete reproduction.

Comments

@armordecai
Copy link

What version of Next.js are you using?

10.0.7

What version of Node.js are you using?

14.15.5

What browser are you using?

Firefox

What operating system are you using?

Linux Mint 19.3 (Ubuntu 18.04)

How are you deploying your application?

next dev

Describe the Bug

This was previously reported in #21038 and was closed as not reproducible. Hopefully the additional information in my report proves helpful. The problem is 100% reproducible on my machine with Next.js 10.0.7 (latest), 10.0.6, and 10.0.5. The problem is resolved by downgrading to 10.0.4.

When I create a new Next.js app using create-next-app (via npx), start it in development mode with next dev (via the provided NPM dev script), and load http://localhost:3000 in the browser, the following error is raised:

TypeError: Object(...) is not a function
    at MyApp (webpack-internal:///./pages/_app.js:21:91)
    at d (/home/am/www/example/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:33:498)
    at bb (/home/am/www/example/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:36:16)
    at a.b.render (/home/am/www/example/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:42:43)
    at a.b.read (/home/am/www/example/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:41:83)
    at exports.renderToString (/home/am/www/example/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:52:138)
    at Object.renderPage (/home/am/www/example/node_modules/next/dist/next-server/server/render.js:54:851)
    at Function.getInitialProps (webpack-internal:///./node_modules/next/dist/pages/_document.js:135:19)
    at loadGetInitialProps (/home/am/www/example/node_modules/next/dist/next-server/lib/utils.js:5:101)
    at renderToHTML (/home/am/www/example/node_modules/next/dist/next-server/server/render.js:54:1142)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async /home/am/www/example/node_modules/next/dist/next-server/server/next-server.js:107:97
    at async /home/am/www/example/node_modules/next/dist/next-server/server/next-server.js:100:142
    at async DevServer.renderToHTMLWithComponents (/home/am/www/example/node_modules/next/dist/next-server/server/next-server.js:132:387)
    at async DevServer.renderToHTML (/home/am/www/example/node_modules/next/dist/next-server/server/next-server.js:133:522)

If I use next build && next start instead, no error is raised, and the app loads (in production mode) as expected. I haven't touched any of the files generated by create-next-app or run any other commands inside the project directory.

Expected Behavior

I expected the app to compile and run in development mode, like Next.js apps usually do.

To Reproduce

  1. npx create-next-app example
  2. cd example
  3. npm run dev
@armordecai armordecai added the bug Issue was opened via the bug report template. label Feb 16, 2021
@timneutkens
Copy link
Member

This is still not reproducible based on the steps provided. Please provide a full reproduction in a repository.

@timneutkens timneutkens added the please add a complete reproduction Please add a complete reproduction. label Feb 16, 2021
@ostseb
Copy link

ostseb commented Feb 18, 2021

@armordecai I'm had the same issue. What's your NODE_ENV set to? I can reproduce it with NODE_ENV=production

Works

npm run dev

Fails

NODE_ENV=production npm run dev

@armordecai
Copy link
Author

@ostseb You're right. NODE_ENV is globally set to "production" for some reason; unsetting it allows npm run dev to work.

@timneutkens
Here is the result of the steps listed in my report: https://github.com/armordecai/nextjs-issue-22206

But I think NODE_ENV is probably the real issue. npm run dev should either work with NODE_ENV=production or exit with an informative error if that's not possible anymore in 10.0.5 and up. It works in 10.0.4, and probably in older versions, but I didn't try any more versions after I found one that worked.

@ijjk
Copy link
Member

ijjk commented Sep 23, 2021

Closing in favor of #19046

@ijjk ijjk closed this as completed Sep 23, 2021
@xiaoxixi6633

This comment has been minimized.

@xiaoxixi6633

This comment has been minimized.

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. please add a complete reproduction Please add a complete reproduction.
Projects
None yet
Development

No branches or pull requests

6 participants