我的项目可以在本地计算机上完美运行,但是在尝试将其实时部署到Heroku时出现此错误:
我遇到错误:发生未处理的异常:找不到模块'@ angular-devkit / build-angular / package.json'
我还更新了Heroku引擎以使其与本地计算机相匹配:
"engines": {
"node": "12.16.2",
"npm": "6.14.4"
}
这就是我的开发依赖项:
"@angular-devkit/build-angular": "^0.901.1"
以下是完整的Heroku日志--tail错误:
admin-platform@0.0.0 start /app
ng serve
An unhandled exception occurred: Cannot find module '@angular-devkit/build-angular/package.json'
Require stack:
/app/node_modules/@angular/cli/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js
/app/node_modules/@angular/cli/node_modules/@angular-devkit/architect/node/index.js
/app/node_modules/@angular/cli/models/architect-command.js
/app/node_modules/@angular/cli/commands/serve-impl.js
/app/node_modules/@angular-devkit/schematics/tools/export-ref.js
/app/node_modules/@angular-devkit/schematics/tools/index.js
/app/node_modules/@angular/cli/utilities/json-schema.js
/app/node_modules/@angular/cli/models/command-runner.js
/app/node_modules/@angular/cli/lib/cli/index.js
/app/node_modules/@angular/cli/lib/init.js
/app/node_modules/@angular/cli/bin/ng
提前谢谢!
答案 0 :(得分:0)
只需从devDependencies复制“ @ angular-devkit / build-angular”:“ ^ 0.901.1”到package.json文件中的依赖项即可! 几分钟前出现了同样的问题。
"dependencies": {
"@angular-devkit/build-angular": "^0.901.1",
...
}
请确保将启动脚本更改为“ node server.js”或服务器文件的名称,以进行进一步的故障排除,此处提供了有关如何在heroku https://medium.com/@ryanchenkie_40935/angular-cli-deployment-host-your-angular-2-app-on-heroku-3f266f13f352