React 和 Vercel:错误:命令“npm run build”以 1 退出?

布伦南·波洛克

我正在尝试将一个简单的 create-react-app 部署到 vercel 并不断获取此构建日志,并在标题中显示错误。有谁知道如何解决这个问题?我分叉并克隆了两个存储库,一个是服务器,另一个是客户端应用程序,我正在尝试部署客户端应用程序。谢谢!

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    > [email protected] 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    > [email protected] postinstall /vercel/workpath0/node_modules/core-js
19:03:02.298    > node -e "try{require('./postinstall')}catch(e){}"
19:03:02.367    > [email protected] postinstall /vercel/workpath0/node_modules/core-js-pure
19:03:02.367    > node -e "try{require('./postinstall')}catch(e){}"
19:03:02.458    > [email protected] postinstall /vercel/workpath0/node_modules/ejs
19:03:02.458    > node ./postinstall.js
19:03:04.533    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/webpack-dev-server/node_modules/fsevents):
19:03:04.533    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
19:03:04.540    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/watchpack-chokidar2/node_modules/fsevents):
19:03:04.541    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
19:03:04.549    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
19:03:04.549    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: 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    > [email protected] 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! [email protected] 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 [email protected] 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 警告而引发错误。

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

...
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
...

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

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


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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

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

尝试将 react-app 部署到 Vercel 时出错(错误:命令“yarn run build”以 1 退出)

部署到 Vercel 时出错(错误:命令“npm run build”以 127 退出)

命令“ npm run build---prod”退出,出现代码1错误

執行 npm run build 命令後,React app docker 容器退出/重新啟動

npm run build in php Laravel 挂起或退出

在“npm run build”之后,material-ui 和 react 不会重现相同的行为?

无法在我的React应用程序中运行'npm run build'/'npm run deploy'命令

“dotnet build”命令失败并出现错误 MSB6006:“csc.exe”以代码 1 退出

“ npm r build”和“ npm run build”的区别?

使make命令退出1

Android NDK.Build命令失败。未定义参考。clang ++:错误:链接器命令失败,退出代码为1

CRA 中的 setupProxy 文件使 react-scripts 启动失败,命令失败,退出代码 1 错误

clang:错误:链接器命令失败,退出代码为1,react-native

无法部署 React 项目。错误是命令失败,退出代码为 1

构建失败,并显示错误“找不到文件”和“链接器命令失败,并显示退出代码1”

CMake错误:链接器命令失败,并显示退出代码1和cpp.o文件

错误:命令错误,退出状态为1

npm install和npm run build有什么区别?

运行“npm run build”时出现 npm run build 错误

Hololens Build Failing-命令AssemblyConverter.exe退出,代码为1

命令失敗,退出代碼 134:npm run generate

在React中使用“ npm run build”后,路由未加载

为什么“npm run build”会产生错误“react-scripts Permission denied”?

如何解决npm run build“无法编译。无法缩小包”的React应用错误?

该命令以代码1退出

SSH命令的退出代码1

登录/退出React路由和ExpressJS路由

如何从钩子退出“cordova build”命令?