错误:命令“npm run build”以 1. vercel deploy 错误退出,next.js

时间:2021-05-19 12:34:50

标签: reactjs npm next.js vercel emotion

我试图用 vercel 和我的 git repostiory 部署我的 next.js 网站。这是我从 vercel 部署网站控制台收到的消息。 尝试安装 emoition/react,但仍然无法正常工作。

   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 个答案:

答案 0 :(得分:0)

Error: Command “npm run build” exited with 1 不是 Vercel 显示的实际错误。

实际错误以红色显示在日志中。

示例错误日志 vercel error log

在您的日志中,您可以看到导致构建过程失败的 Can't resolve '@emotion/styled' 错误。

你必须先修复它。