ng build --configuration production causes This call to "require" will not be bundled because...

Discussão em 'Angular' iniciado por rminaj, Novembro 9, 2024.

  1. rminaj

    rminaj Guest

    After doing some research, I still can't find a fix to my issue. After updating npm, angular, node(because I saw https://github.com/angular/angular-cli/issues/27674) and increasing maximumError budget(because I saw https://stackoverflow.com/a/68340281/10464730) and if I'm not mistaken I also already did a project update to include ssr but the issue still exist. Here's the output when I do a


    ng build --configuration production --verbose
    ​

    :


    Building...

    polyfills-FFHMD2TL.js 33.7kb

    ⚡ Done in 31ms

    polyfills.server.mjs 262.3kb

    ⠙ Building...

    main-K43KHCE6.js 217.9kb

    ⠸ Building... ● [DEBUG] This call to "require" will not be bundled because the argument is not a string literal [unsupported-require-call]

    node_modules/express/lib/view.js:72:13:
    72 │ var fn = require(mod).__express;
    ╵ ~~~~~~~ ⠼ Building...


    server.mjs 1.1mb ⚠️ chunk-DPD2CJOV.mjs
    525.3kb chunk-SNU752KB.mjs 12.4kb chunk-VCVCHJZV.mjs 11.8kb chunk-5XUXGTUW.mjs 2.5kb render-utils.server.mjs 1.4kb main.server.mjs 149b

    Browser bundles Initial chunk files | Names | Raw size | Estimated transfer size main-K43KHCE6.js | main
    | 223.11 kB | 59.65 kB polyfills-FFHMD2TL.js | polyfills | 34.52 kB | 11.28 kB styles-WCBAZ6MA.css | styles | 1.16 kB |
    337 bytes

    | Initial total | 258.78 kB | 71.26 kB


    Server bundles Initial chunk files | Names | Raw size server.mjs | server | 1.11 MB | chunk-DPD2CJOV.mjs | - | 537.95 kB | polyfills.server.mjs | polyfills.server | 268.60 kB | chunk-SNU752KB.mjs | - | 12.68 kB | chunk-5XUXGTUW.mjs | - | 2.55 kB | render-utils.server.mjs | render-utils.server | 1.46 kB | main.server.mjs | main.server | 149 bytes |

    Lazy chunk files | Names | Raw size chunk-VCVCHJZV.mjs | xhr2 | 12.07 kB |

    Prerendered 1 static route. Application bundle generation complete. [5.198 seconds]
    ​

    Btw, ng serve is working just fine on my local

    Here's my package.json:

    {
    "name": "my-project-name",
    "version": "0.0.0",
    "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test",
    "serve:ssr:my-project-name": "node dist/my-project-name/server/server.mjs"
    },
    "private": true,
    "dependencies": {
    "@angular/animations": "^18.2.11",
    "@angular/common": "^18.2.11",
    "@angular/compiler": "^18.2.11",
    "@angular/core": "^18.2.11",
    "@angular/forms": "^18.2.11",
    "@angular/platform-browser": "^18.2.11",
    "@angular/platform-browser-dynamic": "^18.2.11",
    "@angular/platform-server": "^18.2.11",
    "@angular/router": "^18.2.11",
    "@angular/ssr": "^18.2.11",
    "express": "^4.18.2",
    "my-project-name": "file:",
    "rxjs": "~7.8.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.14.10"
    },
    "devDependencies": {
    "@angular-devkit/build-angular": "^18.2.11",
    "@angular/cli": "^18.2.11",
    "@angular/compiler-cli": "^18.2.11",
    "@types/express": "^4.17.17",
    "@types/jasmine": "~5.1.0",
    "@types/node": "^18.18.0",
    "jasmine-core": "~5.1.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.2.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.1.0",
    "typescript": "~5.4.2"
    }
    }


    And here's my environment details:


    Angular CLI: 18.2.11 Node: 20.12.2 Package Manager: npm 10.9.0 OS: win32 x64

    Angular: 18.2.11 ... animations, cli, common, compiler, compiler-cli, core, forms ... platform-browser, platform-browser-dynamic, platform-server ... router, ssr
    ​

    Continue reading...

Compartilhe esta Página