How can I fix these errors with npm run build on the Next.js default project?


I’m a graphic student trying to learn something further than classic HTML/CSS.

I want to build the default Next.js app, which you can get by npm create-next-app filename.

It certainly works when npm run dev. I can see the index page on localhost:3000.
But npm run build gets:

% npm run build

> test@0.1.0 build /Users/minori/Documents/portfolio/test
> next build

info  - Checking validity of types  

Failed to compile.

8:7  Error: Missing "key" prop for element in array  react/jsx-key
/*almost same messages repeated for every line*/
63:13  Error: Missing "key" prop for element in array  react/jsx-key

info  - Need to disable some ESLint rules? Learn more here:
npm ERR! errno 1
npm ERR! test@0.1.0 build: `next build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the test@0.1.0 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!     /Users/minori/.npm/_logs/2022-02-25T17_53_21_317Z-debug.log

And here is the debug log:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'build' ]
2 info using npm@6.14.15
3 info using node@v14.17.6
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle test@0.1.0~prebuild: test@0.1.0
6 info lifecycle test@0.1.0~build: test@0.1.0
7 verbose lifecycle test@0.1.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle test@0.1.0~build: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/minori/Documents/portfolio/test/node_modules/.bin:/Users/minori/.npm-global/lib/node_modules/n/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/minori/bin:/opt/osxws/bin:/opt/osxws/sbin
9 verbose lifecycle test@0.1.0~build: CWD: /Users/minori/Documents/portfolio/test
10 silly lifecycle test@0.1.0~build: Args: [ '-c', 'next build' ]
11 silly lifecycle test@0.1.0~build: Returned: code: 1  signal: null
12 info lifecycle test@0.1.0~build: Failed to exec build script
13 verbose stack Error: test@0.1.0 build: `next build`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:400:28)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:400:28)
13 verbose stack     at maybeClose (internal/child_process.js:1055:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid test@0.1.0
15 verbose cwd /Users/minori/Documents/portfolio/test
16 verbose Darwin 20.3.0
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
18 verbose node v14.17.6
19 verbose npm  v6.14.15
20 error code ELIFECYCLE
21 error errno 1
22 error test@0.1.0 build: `next build`
22 error Exit status 1
23 error Failed at the test@0.1.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

I already tried npm install -g npmrm -rf node_modulesnpm install, re-installing node.js, npm cache clear --force and rm package-lock.json.

Does anyone know what the problem is?
What else can I try now?


It’s not you, there is an issue logged with eslint-plugin-react that create-next-app uses, if they haven’t already done so (try npm create-next-app again) you can find eslint-plugin-react in your package.json to version 7.29.1

You can see the Vercel team noting the change and the eslint-plugin-react author’s responding

Answered By – Ramakay

Answer Checked By – Cary Denson (AngularFixing Admin)

Leave a Reply

Your email address will not be published.