Error: Command "npm run build" exited with 1. vercel deploy error with next.js

Viewed 2577

I was trying to deploy my next.js website with vercel and my git repostiory. This is the message I get from vercel deploy website console. Tried to install emoition/react and its still not working.

   14:59:59.757     Cloning github.com/dor29494/my-app (Branch: test, Commit: 400d8a4)
15:00:00.829    Cloning completed: 1.072s
15:00:00.851    Analyzing source code...
15:00:01.658    Installing build runtime...
15:00:04.373    Build runtime installed: 2.715s
15:00:06.725    Build cache not provided
15:00:07.847    Installing dependencies...
15:00:08.325    npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!
15:00:19.992    > core-js@3.6.5 postinstall /vercel/path0/node_modules/core-js
15:00:19.992    > node -e "try{require('./postinstall')}catch(e){}"
15:00:20.088    > protobufjs@6.10.2 postinstall /vercel/path0/node_modules/protobufjs
15:00:20.088    > node scripts/postinstall
15:00:20.443    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
15:00:20.443    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
15:00:20.445    added 539 packages from 364 contributors in 12.152s
15:00:20.626    31 packages are looking for funding
15:00:20.626      run `npm fund` for details
15:00:20.648    Detected Next.js version: 10.0.8
15:00:20.649    Running "npm run build"
15:00:20.861    > learn-starter@0.1.0 build /vercel/path0
15:00:20.861    > next build
15:00:21.906    info  - Creating an optimized production build...
15:00:21.922    Attention: Next.js now collects completely anonymous telemetry regarding usage.
15:00:21.922    This information is used to shape Next.js' roadmap and prioritize features.
15:00:21.922    You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
15:00:21.922    https://nextjs.org/telemetry
15:00:26.563    Failed to compile.
15:00:26.563    ModuleNotFoundError: Module not found: Error: Can't resolve '@emotion/styled' in '/vercel/path0/node_modules/@material-ui/core/node_modules/@material-ui/styled-engine'
15:00:26.563    > Build error occurred
15:00:26.564    Error: > Build failed because of webpack errors
15:00:26.564        at /vercel/path0/node_modules/next/dist/build/index.js:15:918
15:00:26.564        at runMicrotasks (<anonymous>)
15:00:26.564        at processTicksAndRejections (internal/process/task_queues.js:93:5)
15:00:26.564        at async /vercel/path0/node_modules/next/dist/build/tracer.js:3:470
15:00:26.578    npm ERR! code ELIFECYCLE
15:00:26.578    npm ERR! errno 1
15:00:26.581    npm ERR! learn-starter@0.1.0 build: `next build`
15:00:26.581    npm ERR! Exit status 1
15:00:26.581    npm ERR! 
15:00:26.581    npm ERR! Failed at the learn-starter@0.1.0 build script.
15:00:26.581    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
15:00:26.589    npm ERR! A complete log of this run can be found in:
15:00:26.589    npm ERR!     /vercel/.npm/_logs/2021-05-19T12_00_26_582Z-debug.log
15:00:26.601    Error: Command "npm run build" exited with 1
1 Answers

Error: Command “npm run build” exited with 1 is not an actual error that Vercel is showing.

The actual error is presenting in the log with red color.

Example error log vercel error log

In your log, you can see Can't resolve '@emotion/styled' error that causes the building process fail.

You have to fix it first.

Related