缺少索引.html通过运行 "npm run build:ssr" 构建 Angular 通用项目后在 dist/浏览器中



安装完Angular universal后:

ng add @nguniversal/express-engine

我去建立项目:

npm run build:ssr

当我运行

服务项目
npm run serve:ssr

错误出现:

Error: Failed to lookup view "index" in views directory "/Users/syahiruddin/RVI-clone/app/dist/functions/dist/functions/browser"
at Function.render (/Users/syahiruddin/RVI-clone/app/dist/functions/server/main.js:55087:17)
at ServerResponse.render (/Users/syahiruddin/RVI-clone/app/dist/functions/server/main.js:56954:7)
at /Users/syahiruddin/RVI-clone/app/dist/functions/server/main.js:201044:13
at Layer.handle [as handle_request] (/Users/syahiruddin/RVI-clone/app/dist/functions/server/main.js:57833:5)
at next (/Users/syahiruddin/RVI-clone/app/dist/functions/server/main.js:58067:13)
at Route.dispatch (/Users/syahiruddin/RVI-clone/app/dist/functions/server/main.js:58042:3)
at Layer.handle [as handle_request] (/Users/syahiruddin/RVI-clone/app/dist/functions/server/main.js:57833:5)
at /Users/syahiruddin/RVI-clone/app/dist/functions/server/main.js:57368:22
at param (/Users/syahiruddin/RVI-clone/app/dist/functions/server/main.js:57440:14)
at param (/Users/syahiruddin/RVI-clone/app/dist/functions/server/main.js:57451:14)

经过几天的检查,我在浏览器文件夹中查看了一下,发现它缺少index.html。我认为这就是错误的原因。或许我错了。

我不知道如何解决这个问题,我检查了我的angular.json。请帮助我,因为我一直在寻找解决这个问题的天。

我发现有另一个错误导致浏览器文件夹中缺少index.html。

Error: bundle initial exceeded maximum budget. Budget 1.00 MB was not met by 418.72 kB with a total of 1.41 MB.

为了解决这个问题,我增加了maximumWarning和maximumError的预算,使其略高于初始值。

angular.json

"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "1.5mb",
"maximumError": "1.5mb"
},

有了这个,它就能够成功地构建了。

最新更新