我在发布我在Vercel中制作的React.js typescript项目时遇到了这样的错误。我一直无法找到解决方案。
Vercel publishing error as follows
- 我的Package Json文件是这样的;**
{
"name": "jodee-frontend",
"version": "1.0.0",
"engines": {
"node": "16.x",
"npm": "8.x"
},
"private": true,
"type": "module",
"dependencies": {
"@hookform/resolvers": "^2.9.10",
"@reduxjs/toolkit": "^1.9.1",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.2",
"@types/node": "^16.18.10",
"@types/react-dom": "^18.0.10",
"eslint-plugin-simple-import-sort": "^8.0.0",
"jwt-decode": "^3.1.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.33.1",
"react-icons": "^4.7.1",
"react-redux": "^8.0.5",
"react-router-dom": "^6.6.0",
"react-scripts": "5.0.1",
"sass": "^1.57.1",
"typescript": "*",
"web-vitals": "^2.1.4",
"yup": "^0.32.11"
},
"scripts": {
"dev": "vite --port 3000",
"build": "vite build",
"preview": "vite preview",
"type-check": "tsc",
"type-check:no-artifact": "tsc --skipLibCheck --noEmit",
"lint:fix": "eslint ./src --ext .jsx,.js,.ts,.tsx --fix --max-warnings=0 --ignore-path ./.gitignore",
"lint:format": "prettier --loglevel warn --write \"./**/*.{js,jsx,ts,tsx,css,md,json}\" ",
"lint": "yarn lint:format && yarn lint:fix ",
"release": "standard-version",
"prepare": "husky install"
},
"lint-staged": {
"./src/**/*.{ts,tsx}": [
"eslint --max-warnings=0",
"prettier --write --ignore-unknown"
]
},
"devDependencies": {
"@commitlint/cli": "^17.3.0",
"@commitlint/config-conventional": "^17.3.0",
"@types/react": "^18.0.26",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.31.0",
"@vitejs/plugin-react": "^3.0.0",
"autoprefixer": "^10.4.13",
"eslint": "^8.0.1",
"eslint-config-prettier": "^8.5.0",
"eslint-config-standard-with-typescript": "^24.0.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-jsx-a11y": "^6.6.1",
"eslint-plugin-n": "^15.0.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-react": "^7.31.11",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-simple-import-sort": "^8.0.0",
"husky": "^8.0.0",
"lint-staged": "^13.0.3",
"postcss": "^8.4.20",
"prettier": "^2.8.1",
"standard-version": "^9.5.0",
"tailwindcss": "^3.2.4",
"typescript": "^4.6.4",
"vite": "^4.0.0"
}
}
- 我的vite.config.js文件如下所示;**
import react from "@vitejs/plugin-react"
import * as path from "path"
import { defineConfig } from "vite"
// https://vitejs.dev/config/
export default defineConfig(async ({ mode }) => {
return {
plugins: [react()],
resolve: {
alias: [{ find: "@", replacement: path.resolve(__dirname, "./src") }],
},
optimizeDeps: {
esbuildOptions: {
// Node.js global to browser globalThis
define: {
global: "globalThis",
},
},
},
}
})
- 我的tsconfig.json文件是这样的;**
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"rootDir": "./src",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["src/**/*"],
"exclude": ["node_modules"],
"references": [{ "path": "./tsconfig.node.json" }]
}
我在等待这个项目在vercel上发布,但是我经常遇到这个错误,我甚至在Heroku上也遇到过类似的错误。
1条答案
按热度按时间hwazgwia1#
我也遇到过类似的问题。要修复这个问题,请转到你的项目设置=〉常规并覆盖以下命令:
生成命令:Yarn结构
输出目录:距离
开发指挥部:Yarn偏差
PS:用你的包裹管理器替换Yarn。