简体   繁体   English

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

[英]Vercel Deployment Error: Command "npm run build" exited with 1

I am developing a React app in VS Code.我正在 VS Code 中开发 React 应用程序。 I used create-react-app for setup.我使用 create-react-app 进行设置。 I can run the project without any problem with npm start .我可以毫无问题地运行项目npm start When I tried to publish the project with Vercel I got errors:当我尝试使用 Vercel 发布项目时出现错误:

Already tried deleting node_modules and npm install again.已经尝试删除 node_modules 并npm install

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

You can see the logs below:你可以看到下面的日志:

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":"any"} (current: {"os":"linux","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":"any"} (current: {"os":"linux","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

Check whether your codes don't have any warnings .检查您的代码是否没有任何warnings If they have warnings try to fix them and deploy again or ignore them by setting environment variable CI to false .如果他们有警告尝试修复它们并再次部署或通过将environment variable CI设置为false来忽略它们。 It would look like this:它看起来像这样:

CI = false

If you are getting this error:如果您收到此错误:

  1. Go to your project setting in vercel.com. Go 到您在 vercel.com 中的项目设置。
  2. Go to General. Go 至一般。
  3. In the "Build & Development Settings", override the Build command and write CI='' npm run build .在“构建和开发设置”中,覆盖构建命令并写入CI='' npm run build

This solved the error for me.这为我解决了错误。

If you are getting this error:如果您收到此错误:

  1. Go to project setting in vercel.com. Go 到 vercel.com 中的项目设置。
  2. Go to General. Go 给将军。
  3. In the "Build & Development Settings", override the Build command and write CI='' npm run build .在“Build & Development Settings”中,覆盖 Build 命令并写入CI='' npm run build This solved the error for me.这为我解决了错误。

Set CI Environment Variable to false Using Vercel CLI使用 Vercel CLI 将 CI 环境变量设置为 false

Go to your project directory and then open the terminal and type Go 到您的项目目录,然后打开终端并键入

$ vercel env add CI

Vercel CLI 24.0.0
? What’s the value of CLI? false
? Add CLI to which Environments (select multiple, press a)? Production, Preview, Development
✅  Added Environment Variable CLI to Project <Project-name> [776ms]

Now, go to your Vercel app => Settings => Environment Variable Their your will see CLI key has a value set to false现在,go 到您的 Vercel 应用程序 => 设置 => 环境变量 他们将看到CLI键的值设置为false

You simply you check your package.json in your project folder, check the build script in the json object.您只需在项目文件夹中检查 package.json,检查 json ZA8CFDE633114EB2AC96.B8 中的构建脚本

'script':
{
   "dev": "next dev",
             ==>  "build": "next build", 
    "start": "next start",
    "lint": "next lint"
}

I'm godly我很虔诚

For Deployment follow this procedure if you are getting errors...对于部署,如果您遇到错误,请遵循此过程...

  1. Run yarn dev in your project folder.在项目文件夹中运行 yarn dev。
  2. Then run terminal as administrator and cd to your project folder then run vercel build command.然后以管理员身份运行终端并 cd 到您的项目文件夹,然后运行 vercel build 命令。
  3. After it finished successfully, delete the folder inside.vercel\output\functions_next\data成功完成后,删除里面的文件夹.vercel\output\functions_next\data
  4. Then run vercel deploy prebuilt -> successful (It worked for me)然后运行 vercel deploy prebuilt -> 成功(对我有用)

Go to project setting in vercel.com. Go 到 vercel.com 中的项目设置。 Go to General. Go 给将军。 In the "Build & Development Settings", override the Build command and write在“构建和开发设置”中,覆盖构建命令并编写

npm run build npm 运行构建

This solved the error for me.这为我解决了错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Vercel 部署错误:命令“yarn run build”以 1 退出 - Vercel Deployment Error: Command "yarn run build" exited with 1 React 和 Vercel:错误:命令“npm run build”以 1 退出? - React and Vercel: Error: Command “npm run build” exited with 1? Vercel 部署构建失败,命令 npm install exited with 1 - Vercel deployment build failed with command npm install exited with 1 错误:命令“npm run build”以 1 退出。vercel 部署错误与 next.js - Error: Command "npm run build" exited with 1. vercel deploy error with next.js 命令“yarn run build”以 1 退出。Vercel 部署 - Command "yarn run build" exited with 1. Vercel deploy 部署到 vercel 时出错,但运行 npm 运行构建时没有错误 - Error deploying to vercel but no errors when I run npm run build Vercel 的 NextJS 构建和部署错误 - NextJS build and deployment error with Vercel 使用 Github 发布 React+dotnet 核心应用程序引发错误 MSB3073 的操作:命令“npm run build”退出,代码为 1 - Publishing React+dotnet core application using Github Actions throwing error MSB3073: The command “npm run build” exited with code 1 影响 vercel 部署但不影响本地构建的错误 - Error affecting vercel deployment but not a local build 如何解决以 1 个错误退出的命令“yarn run build”!? - How to solve Command "yarn run build" exited with 1 Error!?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM