这个错误通常是由于项目中缺少 build scripts 或环境配置不完整所致。首先,在项目目录下运行 ng build
命令以确保本地构建成功。然后,更新或添加所需的 scripts 到 package.json 文件中,例如:
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
}
最后,确认 Github 上源代码所使用的构建系统与本地构建系统一致,例如在 Github Actions 配置中,确保正确设置了 NodeJS 环境、依赖安装、build 脚本等。