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

kqlmhetl  于 2023-10-19  发布在  React
关注(0)|答案(3)|浏览(196)

我一直在尝试将我的repeat-react-app部署到vercel上,但总是出现以下错误。一切都在本地工作,甚至没有错误。我该如何解决?我已经试过在vercel项目设置上获取变量,但一无所获。
我用npm run build构建,而不用Yarn做任何事情,所以我不明白。

14:50:48    511[1/4] Resolving packages                                                                                 
14:50:49    609[2/4] Fetching packages                                                                                  
14:51:06    414info fsevents@2  3   2: The platform "linux" is incompatible with this module                                                                            
14:51:06    414info "fsevents@2 3   2" is an optional dependency and failed compatibility check  Excluding it from installation                                                                     
14:51:06    431info fsevents@1  2   13: The platform "linux" is incompatible with this module                                                                           
14:51:06    431info "fsevents@1 2   13" is an optional dependency and failed compatibility check     Excluding it from installation                                                                     
14:51:06    444[3/4] Linking dependencies                                                                                   
14:51:06    446warning " > @testing-library/user-event@12   8   3" has unmet peer dependency "@testing-library/dom@>=7  21  4"                                                                  
14:51:06    447warning " > react-lottie@1   2   3" has incorrect peer dependency "react@^0  14  7 || ^15    0   0 || ^16    0   0"                                                  
14:51:06    451warning "react-scripts > @typescript-eslint/eslint-plugin > tsutils@3    20  0" has unmet peer dependency "typescript@>=2    8   0 || >= 3   2   0-dev || >= 3   3   0-dev || >= 3   4   0-dev || >= 3   5   0-dev || >= 3   6   0-dev || >= 3   6   0-beta || >= 3  7   0-dev || >= 3   7   0-beta" 
14:51:20    599[4/4] Building fresh packages                                                                                    
14:51:21    325success Saved lockfile                                                                                   
14:51:21    331Done in 32   90s                                                                             
14:51:21    551Running "yarn run build"                                                                                 
14:51:21    736yarn run v1  22  10                                                                          
14:51:21    764$ CI=false && react-scripts build                                                                                    
14:51:23    059Creating an optimized production build                                                                                   
14:51:23    841Browserslist: caniuse-lite is outdated    Please run:                                                                                
14:51:23    842npx browserslist@latest --update-db                                                                                  
14:51:23    842                                                                                 
14:51:23    842Why you should do it regularly:                                                                                  
14:51:23    842https://github   com/browserslist/browserslist#browsers-data-updating                                                                                
14:51:26    498Failed to compile                                                                                    
14:51:26    498                                                                                 
14:51:26    502 /src/components/header/Banner   js                                                                          
14:51:26    502Cannot find file 'C:/Users/gabri/OneDrive/Documentos/React/portifolio/src/assets/img/profile/eu  png' in '   /src/components/header'                                                                         
14:51:26    502                                                                                 
14:51:26    503                                                                                 
14:51:26    526 error Command failed with exit code                                                                                 
14:51:26    526 info Visit https://yarnpkg  com/en/docs/cli/run for documentation about this command                                                                                
14:51:26    542 Error: Command "yarn run build" exited with 1

我的package.json

{
  "name": "portifolio",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-lottie": "^1.2.3",
    "react-scripts": "4.0.3",
    "web-vitals": "^1.0.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "CI=false && react-scripts build",  
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}
fzwojiic

fzwojiic1#

错误消息显示:
Cannot find file 'C:/Users/gabri/OneDrive/Documentos/React/ports/src/assets/img/profile/eu png' in ' /src/components/header'
检查您是否在头组件中正确引用了此文件。

rsaldnfx

rsaldnfx2#

在Vercel中,当你从GitHub选择你的项目时,你可以在Configure ProjectBox中添加环境变量,因为 NameCIVALUEfalse,然后部署它,我假设它会解决你的问题。

sy5wg1nm

sy5wg1nm3#

我得到了同样的错误,你必须检查你正在使用的节点的版本。节点版本18会给你这个错误,也许你使用的是节点版本16。在我的情况下,我使用版本16。我的解决方案如下:package.json中

"engines": {
    "node": "16"
},

相关问题