Skip to content

@nestjs/ng-universal not working with Angular 13 - Error [ERR_REQUIRE_ESM]: require() of ES Module #833

Open
@LeParadoxHD

Description

@LeParadoxHD

I'm submitting a...


[ ] Regression
[X] Bug report
[ ] Feature request
[X] Documentation issue or request
[ ] Support request

Current behavior

[5:35:48 PM] File change detected. Starting incremental compilation...
[5:36:02 PM] Found 0 errors. Watching for file changes.

/code/api/node_modules/@nestjs/ng-universal/dist/angular-universal.module.js:26
const common_1 = require("@angular/common");
                 ^
Error [ERR_REQUIRE_ESM]: require() of ES Module /code/api/node_modules/@angular/common/fesm2015/common.mjs not supported.
Instead change the require of /code/api/node_modules/@angular/common/fesm2015/common.mjs to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/code/api/node_modules/@nestjs/ng-universal/dist/angular-universal.module.js:26:18)
    at Object.<anonymous> (/code/api/node_modules/@nestjs/ng-universal/dist/index.js:13:14)
    at Object.<anonymous> (/code/api/node_modules/@nestjs/ng-universal/index.js:6:10)
    at Object.<anonymous> (/code/api/api_dist/server/app.module.js:15:24)
    at Object.<anonymous> (/code/api/api_dist/main.js:15:22)

Expected behavior

No TS error.

Minimal reproduction of the problem with instructions

import { AngularUniversalModule } from '@nestjs/ng-universal';

Environment

Nest version: 8.2.6
 
For Tooling issues:
- Node version: v16.13.1
- Platform:  Linux (inside Docker)

package.json:

{
	"dependencies": {
		"@angular/animations": "~13.2.2",
		"@angular/cdk": "^13.2.2",
		"@angular/common": "~13.2.2",
		"@angular/compiler": "~13.2.2",
		"@angular/core": "~13.2.2",
		"@angular/forms": "~13.2.2",
		"@angular/material": "^13.2.2",
		"@angular/platform-browser": "~13.2.2",
		"@angular/platform-browser-dynamic": "~13.2.2",
		"@angular/platform-server": "~13.2.2",
		"@angular/router": "~13.2.2",
		"@casl/ability": "^5.4.3",
		"@nestjs/bull": "^0.4.2",
		"@nestjs/common": "^8.2.6",
		"@nestjs/core": "^8.2.6",
		"@nestjs/jwt": "^8.0.0",
		"@nestjs/ng-universal": "^6.0.0",
		"@nestjs/passport": "^8.1.0",
		"@nestjs/platform-express": "^8.2.6",
		"@nestjs/platform-socket.io": "^8.2.6",
		"@nestjs/schedule": "^1.0.2",
		"@nestjs/serve-static": "^2.2.2",
		"@nguniversal/express-engine": "^13.0.2",
		"@typegoose/typegoose": "^9.5.0",
		"express": "^4.15.2",
		"http-proxy": "^1.18.1",
		"redis": "^3.1.2",
		"reflect-metadata": "^0.1.13",
		"rimraf": "^3.0.2",
		"rxjs": "^7.5.2",
		"tslib": "^2.3.1",
		"zone.js": "~0.11.4"
	},
	"devDependencies": {
		"@nestjs/cli": "^8.2.0",
		"@nestjs/schematics": "^8.0.5",
		"@nestjs/testing": "^8.2.6",
		"ts-node": "^10.4.0",
		"typescript": "^4.5.5"
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions