Errors when trying to deploy react-app to Vercel (Error: Command "yarn run build" exited with 1)
Errors when trying to deploy react-app to Vercel (Error: Command "yarn run build" exited with 1)
我一直在尝试将我的 create-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"
]
}
}
错误消息说:
Cannot find file
'C:/Users/gabri/OneDrive/Documentos/React/portifolio/src/assets/img/profile/eu
png' in ' /src/components/header'
检查您是否在 header 组件中正确引用此文件。
而不是在 package.json 中写 CI false
在 Vercel 中,当您从 GitHub 中选择您的项目时,在 配置项目 框中,您可以添加环境变量,因为 Name 是 CI
并且 VALUE 是 false
然后部署它,我想它会解决你的问题。
我一直在尝试将我的 create-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"
]
}
}
错误消息说:
Cannot find file 'C:/Users/gabri/OneDrive/Documentos/React/portifolio/src/assets/img/profile/eu png' in ' /src/components/header'
检查您是否在 header 组件中正确引用此文件。
而不是在 package.json 中写 CI false
在 Vercel 中,当您从 GitHub 中选择您的项目时,在 配置项目 框中,您可以添加环境变量,因为 Name 是 CI
并且 VALUE 是 false
然后部署它,我想它会解决你的问题。