我一直在尝试部署我的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"
]
}
}
错误提示:
找不到文件"C:/用户/加布里/OneDrive/Documentos/反应/portifolio/src/资产/img/资料/欧盟Png ' in '/src/components/header'
检查你是否在你的头组件中正确引用了这个文件。
不要在package.json中写CI false在Vercel中,当你从GitHub和中选择你的项目时,配置项目框中可以添加环境变量,Name为CI
,VALUE为false
然后部署它,我想它会解决你的问题。
我得到了同样的错误,你必须检查你正在使用的节点的版本。节点版本18给出了这个错误,也许您使用的是节点v16。在我的例子中,我使用的是版本16。我的解决方案如下:在package.json
"engines": {
"node": "16"
},