Ng-19 [错误]“src/main.server.ts”中没有与导入“default”匹配的导出

问题描述 投票:0回答:1

我正在尝试将我的申请从 18 更新到 19。我面临这个问题。

enter image description here

我添加了

export default AppServerModule

之后我收到了与vite相关的问题

enter image description here

main.server.ts

import '@angular/platform-server/init';

import { enableProdMode } from '@angular/core';

import { environment } from './environments/environment';
import { AppServerModule } from 'main.server';

if (environment.production) {
  enableProdMode();
}

export { AppServerModule } from './app/app.server.module';

package.json

 "dependencies": {
    "@angular-builders/custom-webpack": "^18.0.0",
    "@angular/animations": "^19.0.0",
    "@angular/cdk": "^19.0.0",
    "@angular/common": "19.0.0",
    "@angular/compiler": "19.0.0",
    "@angular/core": "19.0.0",
    "@angular/fire": "^18.0.1",
    "@angular/forms": "19.0.0",
    "@angular/material": "^19.0.0",
    "@angular/material-moment-adapter": "19.0.0",
    "@angular/platform-browser": "19.0.0",
    "@angular/platform-browser-dynamic": "19.0.0",
    "@angular/platform-server": "19.0.0",
    "@angular/router": "19.0.0",
    "@angular/ssr": "^19.0.0",
    "@aws-sdk/client-s3": "^3.697.0",
    "@aws-sdk/lib-storage": "^3.697.0",
    "@aws-sdk/s3-request-presigner": "^3.697.0",
    "@aws-sdk/signature-v4-crt": "^3.696.0",
    "@aws-sdk/util-user-agent-node": "^3.696.0",
    "@calumk/editorjs-columns": "^0.3.2",
    "@compodoc/compodoc": "^1.1.26",
    "@editorjs/attaches": "^1.3.0",
    "@editorjs/checklist": "^1.6.0",
    "@editorjs/code": "^2.9.3",
    "@editorjs/editorjs": "^2.30.7",
    "@editorjs/embed": "^2.7.6",
    "@editorjs/header": "^2.8.8",
    "@editorjs/image": "^2.10.0",
    "@editorjs/link": "^2.6.2",
    "@editorjs/list": "^2.0.2",
    "@editorjs/paragraph": "^2.11.6",
    "@editorjs/quote": "^2.7.2",
    "@editorjs/raw": "^2.5.0",
    "@editorjs/table": "^2.4.2",
    "@editorjs/underline": "^1.2.1",
    "@editorjs/warning": "^1.4.0",
    "@formio/angular": "^7.0.0",
    "@fortawesome/fontawesome-free": "^6.7.1",
    "@fullcalendar/angular": "^6.1.15",
    "@fullcalendar/core": "^6.1.15",
    "@fullcalendar/daygrid": "^6.1.15",
    "@fullcalendar/interaction": "^6.1.15",
    "@fullcalendar/list": "^6.1.15",
    "@fullcalendar/moment": "^6.1.15",
    "@fullcalendar/rrule": "^6.1.15",
    "@fullcalendar/timegrid": "^6.1.15",
    "@nguniversal/module-map-ngfactory-loader": "^8.2.6",
    "@pdftron/webviewer": "^11.0.0",
    "@types/jspdf": "^2.0.0",
    "@types/stripe": "^8.0.417",
    "algoliasearch": "^5.15.0",
    "angular-instantsearch": "^4.4.3",
    "angular-sanitize": "^1.8.3",
    "aos": "^2.3.4",
    "apexcharts": "^4.0.0",
    "archiver": "^7.0.1",
    "bootstrap": "^5.3.3",
    "crypto-browserify": "^3.12.1",
    "crypto-es": "^2.1.0",
    "crypto-js": "^4.2.0",
    "domino": "^2.1.6",
    "domino-ext": "^2.1.4",
    "dotenv": "^16.4.5",
    "editorjs-alert": "^1.1.4",
    "editorjs-html": "^3.4.3",
    "editorjs-style": "^3.0.3",
    "editorjs-text-color-plugin": "^2.0.4",
    "editorjs-toggle-block": "^0.3.16",
    "express": "^4.21.1",
    "firebase": "^11.0.2",
    "fs-extra": "^11.2.0",
    "gapi-script": "^1.2.0",
    "highlight.js": "11.10.0",
    "html2canvas": "^1.4.1",
    "html2pdf.js": "^0.10.2",
    "i": "^0.3.7",
    "instantsearch.js": "^4.75.5",
    "jspdf": "^2.5.2",
    "jspdf-autotable": "^3.8.4",
    "leader-line": "^1.0.7",
    "lodash-es": "4.17.21",
    "material-steppers": "^2.0.0",
    "moment": "^2.30.1",
    "ng-apexcharts": "^1.13.0",
    "ng-quill": "^4.5.3",
    "ng-starrating": "^1.0.20",
    "ng-stripe-checkout": "^1.0.4",
    "ng2-pdfjs-viewer": "^18.0.0",
    "ngx-device-detector": "^8.0.0",
    "ngx-doc-viewer": "^15.0.1",
    "ngx-extended-pdf-viewer": "^22.0.0-alpha.10",
    "ngx-mat-select-search": "^7.0.8",
    "node-fetch": "^3.3.2",
    "npm": "^10.9.0",
    "perfect-scrollbar": "1.5.6",
    "pm2": "^5.4.3",
    "quill": "2.0.2",
    "quill-emoji": "^0.2.0",
    "request": "^2.88.2",
    "rrule": "2.8.1",
    "rxjs": "^7.8.1",
    "rxjs-compat": "^6.6.7",
    "source-map-explorer": "^2.5.3",
    "split-file": "^2.3.0",
    "stripe": "^17.4.0",
    "stripe-angular": "^1.9.3",
    "sweetalert2": "^11.14.5",
    "title-editorjs": "^1.0.2",
    "ts-md5": "^1.3.1",
    "tslib": "2.8.1",
    "video.js": "^8.19.1",
    "videojs-logo": "^3.0.0",
    "videojs-markers": "^1.0.1",
    "videojs-playlist": "^5.2.0",
    "videojs-seek-buttons": "^3.0.1",
    "vis": "^4.21.0-EOL",
    "vis-data": "^7.1.9",
    "vis-network": "^9.1.9",
    "vjs": "^0.1.8",
    "web-animations-js": "2.3.2",
    "xlsx": "^0.18.5",
    "zone.js": "~0.15.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "19.0.0",
    "@angular/cli": "19.0.0",
    "@angular/compiler-cli": "19.0.0",
    "@angular/language-service": "19.0.0",
    "@formio/js": "^5.0.0-rc.48",
    "@ngx-builders/analyze": "^4.0.0",
    "@ngx-meta/core": "^9.0.0",
    "@types/crypto-js": "4.2.2",
    "@types/express": "^5.0.0",
    "@types/highlight.js": "10.1.0",
    "@types/jasmine": "5.1.4",
    "@types/jasminewd2": "2.0.13",
    "@types/lodash-es": "4.17.12",
    "@types/node": "22.9.1",
    "browser-sync": "^3.0.3",
    "bufferutil": "^4.0.8",
    "codelyzer": "6.0.2",
    "file-saver": "^2.0.5",
    "formiojs": "^4.21.5",
    "jasmine-core": "5.4.0",
    "jasmine-spec-reporter": "7.0.0",
    "karma": "6.4.4",
    "karma-chrome-launcher": "3.2.0",
    "karma-coverage-istanbul-reporter": "3.0.3",
    "karma-jasmine": "5.1.0",
    "karma-jasmine-html-reporter": "2.1.0",
    "ngx-infinite-scroll": "^18.0.0",
    "ngx-moment": "^6.0.2",
    "ngx-owl-carousel-o": "^18.0.0",
    "ngx-pagination": "^6.0.3",
    "ngx-quill": "^27.0.0",
    "protractor": "7.0.0",
    "tailwindcss": "3.4.15",
    "ts-node": "10.9.2",
    "tslint": "6.1.3",
    "typescript": "5.6.3",
    "utf-8-validate": "^6.0.5",
    "ws": "^8.18.0",
    "xhr2": "^0.2.1"
  }
}

angular angular-material angular19
1个回答
0
投票

您可以尝试以下

main.ts
main.server.ts
的配置吗?

我创建了一个新项目来获取最新的正确配置,应该进行相同的设置并且可以解决您的问题。在进行此更改之前,请提交/存储您的更改,以便在失败时可以回滚。

main.server.ts

import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app/app.component';
import { config } from './app/app.config.server';

import { environment } from './environments/environment';
import { enableProdMode } from '@angular/core';

if ((environment as any).production) {
  enableProdMode();
}

const bootstrap = () => bootstrapApplication(AppComponent, config);

export default bootstrap;

main.ts

import { bootstrapApplication } from '@angular/platform-browser';
import { appConfig } from './app/app.config';
import { AppComponent } from './app/app.component';

import { environment } from './environments/environment';
import { enableProdMode } from '@angular/core';

if ((environment as any).production) {
  enableProdMode();
}
bootstrapApplication(AppComponent, appConfig)
  .catch((err) => console.error(err));

Stackblitz 演示 -> cd test -> npm i -> npm run start

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.