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.

Failed To Compile - npm run build after upgrading Next JS

See original GitHub issue

Bug report

Describe the bug

I upgraded next 5.1.0 to next 8.1.0 using this command npm i --save next@latest react@latest react-dom@latest when I’m running npm run build command, this error occurs

λ npm run build

> inviteman@0.0.1 build D:\Documents\GitHub\inviteman
> next build src && npm run build:server

Creating an optimized production build ...

Failed to compile.

../node_modules/next-server/dist/lib/head-manager-context.js
Error: .env["debug"] must be an object, or undefined
    at Array.forEach (<anonymous>)

> Build error occurred
Error: > Build failed because of webpack errors
    at Object.build [as default] (D:\Documents\GitHub\inviteman\node_modules\next\dist\build\index.js:192:15)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! inviteman@0.0.1 build: `next build src && npm run build:server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the inviteman@0.0.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Irene\AppData\Roaming\npm-cache\_logs\2019-04-21T15_52_07_208Z-debug.log

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Upgrade next JS npm i --save next@latest react@latest react-dom@latest
  2. Run npm run build
  3. See error

System information

  • OS: Windows 10
  • Version of Next.js: 8.1.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

13reactions
timneutkenscommented, Apr 21, 2019

Please provide a full reproduction.

1reaction
lkbrcommented, Apr 22, 2019

Not on the Next team, but usually the most helpful thing is a link to a repository of a stock install of Next.js with the minimal amount of code and npm packages needed to recreate the error.

Quite often, this process of stripping down the code/packages and trying to reproduce the problem will lead you to your own solution or to find that the problem was not with Next but with your own custom code or a third party package.

Having done this, you now either have strong case to show that the issue is with Next, or you know the problem is with a third party package and can approach them, or you have a lot of context to ask for help (https://spectrum.chat/next-js being the preferred place to ask).

The final benefit is that you’ve saved the Next team from having to do this for you, and maybe they can use that saved time to further improve Next for us all.

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - Next.js - `npm run build` failed - Stack Overflow
I have package.json in project folder. when I run npm run dev it works just fine. I don't know why he is complaining ......
Read more >
Failed To Compile - npm run build after upgrading Next JS
Bug report Describe the bug I upgraded next 5.1.0 to next 8.1.0 using this command npm i --save next@latest react@latest react-dom@latest ...
Read more >
Migrating from Create React App - Next.js
Let's walk through a series of steps to complete the migration. Updating package.json and dependencies. The first step towards migrating to Next ......
Read more >
Install Next.js on Windows | Microsoft Learn
npm run build for compiling your project. npm start for starting your app in production mode. Open the WSL terminal integrated in VS...
Read more >
Netlify Build Deployment Error because of Webpack - Support
Site Name: MMODoctor Framework: NextJS Application Error: Webpack Build Error ... PM: Installing NPM modules using NPM version 7.21.0 8:54:00 PM: npm WARN ......
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