运行以下 github 操作时,我的构建步骤失败。请注意,我使用的是纱线 v1.22.19。
yml(缩写):
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools
runs-on: ubuntu-latest
environment: staging
steps:
- uses: actions/checkout@v3
- run: yarn install && yarn run build
运行上述操作时,我收到以下错误(缩写)。
Run yarn run build
yarn run v1.22.19
$ tsc && vite build
Version 5.3.3
tsc: The TypeScript Compiler - Version 5.3.3
COMMON COMMANDS
//shortened
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Process completed with exit code 1.
如何避免上述错误?我最近从 npm 切换到yarn,从 CRA 切换到 Vite(如果有的话)。
.yarnrc.yml:
compressionLevel: mixed
enableGlobalCache: true
nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-1.22.19.cjs
package.json:(测试中留下了一些不必要的脚本)
{
"name": "myproject",
"version": "0.1.0",
"type": "module",
"private": true,
"dependencies": {
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"@fontsource/roboto": "^4.5.8",
"@mui/icons-material": "^5.10.16",
"@mui/material": "^5.10.16",
"@reduxjs/toolkit": "^1.9.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^1.2.0",
"dotenv": "^16.3.1",
"env-cmd": "^10.1.0",
"firebase": "^10.7.1",
"firebase-tools": "^13.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-redux": "^8.0.5",
"react-router-dom": "^6.4.3",
"redux-thunk": "^2.4.2",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"build:staging": "env-cmd -f .env.staging npm run build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"preci": "rm -rf node_modules",
"ci": "yarn install --frozen-lockfile",
"setfbproj": "firebase use --clear --project='myproject'"
},
"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"
]
},
"devDependencies": {
"@redux-devtools/core": "^3.13.1",
"@types/react": "^18.2.45",
"@types/react-dom": "^18.2.18",
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.15.0",
"@vitejs/plugin-react": "^4.2.1",
"eslint": "^8.56.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"redux-devtools-extension": "^2.13.9",
"typescript": "^5.3.3",
"vite": "^5.0.10",
"vite-tsconfig-paths": "^4.2.2"
},
"packageManager": "[email protected]"
}
用户错误,我错过了提交 tsconfig,这导致我的 WIP 项目无法构建。