Vercel 部署错误:命令“npm run build”以 1 退出

如何解决Vercel 部署错误:命令“npm run build”以 1 退出?

开发过程中遇到Vercel 部署错误:命令“npm run build”以 1 退出的问题如何解决?下面主要结合日常开发的经验,给出你关于Vercel 部署错误:命令“npm run build”以 1 退出的解决方法建议,希望对你解决Vercel 部署错误:命令“npm run build”以 1 退出有所启发或帮助;

问题描述

我正在 VS Code 中开发 React 应用程序。我使用 create-react-app 进行设置。我可以使用 npm start 毫无问题地运行该项目。当我尝试使用 Vercel 发布项目时出现错误

已尝试再次删除 node_modules 和 npm install

Error! Command "npm run build" exited with 1
Error! Check your logs at https://...

您可以看到以下日志:

13:55:05.231    RetrIEving List of deployment files...
13:55:06.975    Downloading 32 deployment files...
13:55:09.142    Analyzing source code...
13:55:11.289    Installing build runtime...
13:55:15.911    Build runtime installed: 4622.485ms
13:55:20.151    Looking up build cache...
13:55:21.237    Build cache not found
13:55:22.615    Detected package.Json
13:55:22.616    Installing dependencIEs...
13:55:58.492    > core-Js@2.6.12 postinstall /vercel/path0/node_modules/babel-runtime/node_modules/core-Js
13:55:58.492    > node -e "try{require('./postinstall')}catch(e){}"
13:55:58.604    > core-Js@3.9.1 postinstall /vercel/path0/node_modules/core-Js
13:55:58.604    > node -e "try{require('./postinstall')}catch(e){}"
13:55:58.683    > core-Js-pure@3.9.1 postinstall /vercel/path0/node_modules/core-Js-pure
13:55:58.683    > node -e "try{require('./postinstall')}catch(e){}"
13:55:58.801    > eJs@2.7.4 postinstall /vercel/path0/node_modules/eJs
13:55:58.802    > node ./postinstall.Js
13:56:01.182    npm WARN optional SKIPPing OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/webpack-dev-server/node_modules/fsevents):
13:56:01.182    npm WARN notsup SKIPPing OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
13:56:01.191    npm WARN optional SKIPPing OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokIDar2/node_modules/fsevents):
13:56:01.191    npm WARN notsup SKIPPing OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"x64"})
13:56:01.202    npm WARN optional SKIPPing OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
13:56:01.202    npm WARN notsup SKIPPing OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"x64"})
13:56:01.210    added 1985 packages from 812 contributors in 37.99s
13:56:02.556    137 packages are looking for funding
13:56:02.556      run `npm fund` for details
13:56:02.831    Running "npm run build"
13:56:03.100    > last-letter-game@0.1.0 build /vercel/path0
13:56:03.100    > react-scripts build
13:56:04.846    Creating an optimized production build...
13:56:23.548    Treating warnings as errors because process.env.CI = true.
13:56:23.548    Most CI servers set it automatically.
13:56:23.548    Failed to compile.
13:56:23.549    src/components/Counter.Js
13:56:23.549      line 21:6:  React Hook useEffect has a missing dependency: 'props.timeEnds'. Either include it or remove the dependency array  react-hooks/exhaustive-deps
13:56:23.577    npm ERR! code EliFECYCLE
13:56:23.578    npm ERR! errno 1
13:56:23.581    npm ERR! last-letter-game@0.1.0 build: `react-scripts build`
13:56:23.581    npm ERR! Exit status 1
13:56:23.583    npm ERR! 
13:56:23.583    npm ERR! Failed at the last-letter-game@0.1.0 build script.
13:56:23.583    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
13:56:23.592    npm ERR! A complete log of this run can be found in:
13:56:23.592    npm ERR!     /vercel/.npm/_logs/2021-03-28T10_56_23_582Z-deBUG.log
13:56:23.606    Error: Command "npm run build" exited with 1

解决方法

检查您的代码是否没有任何 warnings。如果他们有警告,请尝试修复它们并再次部署或通过将 environment variable CI 设置为 false 来忽略它们。它看起来像这样:

CI = false

编程问答问答

如何将逗号分隔的字符串转换为 Python 中的列表?
对静态 constexpr char[] 的未定义引用
如何获取切片的最后一个元素?
使用正则表达式解析 HTML:为什么不呢?
Composer:如何在不更新旧依赖项的情况下安装另一个依赖项?
pip:强制安装忽略依赖项
我如何 Docker COPY 作为非 root 用户?
存储更改,同时将更改保留在 Git 的工作目录中
微信公众号搜索 “ 程序精选 ” ,选择关注!
微信公众号搜 "程序精选"关注