React 和 Vercel:错误:命令“npm run build"以 1 退出? [英] React and Vercel: Error: Command "npm run build" exited with 1?

查看:186
本文介绍了React 和 Vercel:错误:命令“npm run build"以 1 退出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一个简单的 create-react-app 部署到 vercel 并不断获取此构建日志,其中包含标题中的错误.有人知道怎么修这个东西吗?我分叉并克隆了两个存储库,一个是服务器,另一个是客户端应用程序,我正在尝试部署客户端应用程序.谢谢!

I am trying to deploy a simple create-react-app to vercel and keep getting this build log with the error in the title. Anyone know how to fix this? I forked and cloned two repos, one being a server and the other being a client app, and am trying to deploy the client app. Thanks!

19:02:29.808    Retrieving list of deployment files...
19:02:31.377    Downloading 45 deployment files...
19:02:32.197    Analyzing source code...
19:02:32.619    Installing build runtime...
19:02:34.651    Build runtime installed: 2031.231ms
19:02:36.331    Looking up build cache...
19:02:36.376    Build cache not found
19:02:37.053    Detected package.json
19:02:37.053    Installing dependencies...
19:02:37.517    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!
19:03:02.198    > core-js@2.6.12 postinstall /vercel/workpath0/node_modules/babel-runtime/node_modules/core-js
19:03:02.198    > node -e "try{require('./postinstall')}catch(e){}"
19:03:02.298    > core-js@3.10.1 postinstall /vercel/workpath0/node_modules/core-js
19:03:02.298    > node -e "try{require('./postinstall')}catch(e){}"
19:03:02.367    > core-js-pure@3.6.5 postinstall /vercel/workpath0/node_modules/core-js-pure
19:03:02.367    > node -e "try{require('./postinstall')}catch(e){}"
19:03:02.458    > ejs@2.7.4 postinstall /vercel/workpath0/node_modules/ejs
19:03:02.458    > node ./postinstall.js
19:03:04.533    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/webpack-dev-server/node_modules/fsevents):
19:03:04.533    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
19:03:04.540    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
19:03:04.541    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
19:03:04.549    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
19:03:04.549    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
19:03:04.555    added 2207 packages from 769 contributors in 27.077s
19:03:05.692    137 packages are looking for funding
19:03:05.692      run `npm fund` for details
19:03:05.918    Running "npm run build"
19:03:06.121    > starter-constellations-client@0.1.0 build /vercel/workpath0
19:03:06.121    > react-scripts build
19:03:07.402    Creating an optimized production build...
19:03:12.854    Treating warnings as errors because process.env.CI = true.
19:03:12.854    Most CI servers set it automatically.
19:03:12.854    Failed to compile.
19:03:12.855    src/common/Header.jsx
19:03:12.855      Line 4:1:  Assign arrow function to a variable before exporting as module default  import/no-anonymous-default-export
19:03:12.855    src/common/Navigation.jsx
19:03:12.855      Line 3:1:  Assign arrow function to a variable before exporting as module default  import/no-anonymous-default-export
19:03:12.855    src/home/Constellation.jsx
19:03:12.855      Line 3:1:  Assign arrow function to a variable before exporting as module default  import/no-anonymous-default-export
19:03:12.855    src/home/ConstellationsList.jsx
19:03:12.855      Line 5:1:  Assign arrow function to a variable before exporting as module default  import/no-anonymous-default-export
19:03:12.855    src/home/NoConstellationsMessage.jsx
19:03:12.855      Line 3:1:  Assign arrow function to a variable before exporting as module default  import/no-anonymous-default-export
19:03:12.856    src/home/Search.jsx
19:03:12.856      Line 3:1:  Assign arrow function to a variable before exporting as module default  import/no-anonymous-default-export
19:03:12.882    npm ERR! code ELIFECYCLE
19:03:12.883    npm ERR! errno 1
19:03:12.886    npm ERR! starter-constellations-client@0.1.0 build: `react-scripts build`
19:03:12.886    npm ERR! Exit status 1
19:03:12.886    npm ERR! 
19:03:12.886    npm ERR! Failed at the starter-constellations-client@0.1.0 build script.
19:03:12.886    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
19:03:12.891    npm ERR! A complete log of this run can be found in:
19:03:12.892    npm ERR!     /vercel/.npm/_logs/2021-04-08T00_03_12_886Z-debug.log
19:03:12.898    Error: Command "npm run build" exited with 1
19:03:15.563    Done with "package.json"

推荐答案

日志显示 npm run build 脚本由于 lint 警告而引发错误.

The logs show that the npm run build script is throwing an error because of lint warnings.

以下是我在精神上解析日志的方式(... 意味着我浏览了该部分):

Here's how I mentally parse the logs (... means I skimmed over that section):

...
19:02:37.053    Installing dependencies...
...
19:03:05.918    Running "npm run build"
...
19:03:12.854    Treating warnings as errors because process.env.CI = true.
...
19:03:12.855    src/common/Header.jsx
19:03:12.855      Line 4:1:  Assign arrow function to a variable before exporting as module default  import/no-anonymous-default-export
...
19:03:12.898    Error: Command "npm run build" exited with 1
...

首先,我注意到有关警告被视为错误的消息.

First, I noticed the message about warnings being treated as errors.

其次,由于 lint 规则的格式,我将警告识别为 linter 错误:import/no-anonymous-default-export.

Second, I recognized the warnings as linter errors because of the format of the lint rule: import/no-anonymous-default-export.

您需要解决源代码中的 linter 警告或找到一种在运行 build 脚本时关闭 linter 的方法 (相关).

You need to address the linter warnings in your source code or find a way to turn off the linter when running the build script (related).

这篇关于React 和 Vercel:错误:命令“npm run build"以 1 退出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆