ng-universal: The @nestjs/ng-universal package is not installing correctly in angular 13 getting Package subpath './schematics/utils' is not defined by "exports" in

I’m submitting a…

I have tried to install @nestjs/ng-universal in an an angular 13 project. After running ng add @nestjs/ng-universal ` the package seems to install and it says Package successfully installed but then brings in an error

An unhandled exception occurred: Package subpath ‘./schematics/utils’ is not defined by “exports” in C:\Users\ADMIN\kiambol\node_modules@nguniversal\express-engine\package.json See “C:\Users\ADMIN\AppData\Local\Temp\ng-1gySjP\angular-errors.log” for further details.

Looking at the angular-errors.log file, the full error is:

[error] Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath ‘./schematics/utils’ is not defined by “exports” in C:\Users\ADMIN\kiambol\node_modules@nguniversal\express-engine\package.json at throwExportsNotFound (internal/modules/esm/resolve.js:299:9) at packageExportsResolve (internal/modules/esm/resolve.js:522:3) at resolveExports (internal/modules/cjs/loader.js:449:36) at Function.Module._findPath (internal/modules/cjs/loader.js:489:31) at Function.Module._resolveFilename (internal/modules/cjs/loader.js:875:27) at Function.Module._load (internal/modules/cjs/loader.js:745:27) at Module.require (internal/modules/cjs/loader.js:961:19) at require (internal/modules/cjs/helpers.js:92:18) at Object.<anonymous> (C:\Users\ADMIN\kiambol\node_modules@nestjs\ng-universal\schematics\install\index.js:15:17) at Module._compile (internal/modules/cjs/loader.js:1072:14)

Expected behaviour The package was expected to install correctly install all dependencies and create the server files. It does not create the server folder and the server file.

I wanted to test the npm package that uses @nguniversal/express-engine and used ng add to see if my project is correctly configured and found out that @nguniversal/express-engine works correctly. I came in to a conclusion that the nestjs universal package might not be compatible with angular 13 yet.

Am I doing anything wrong?

I had tried to create new projects to test it and still arrived at the same error. Please help out I like using Nestjs though it seems at the moment am going to do the current server rendered angular project with @nguniversal/express-engine

Tools I am using Nodejs version 14.17.6, Angular 13 and Windows 11

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 23
  • Comments: 25

Commits related to this issue

Most upvoted comments

The same problem here. It would be nice if someone from nestjs team take a look at this issue.

Has anybody from the team had a look at this issue yet?

Temporary workaround:

  1. Install manually npm i -D @nguniversal/express-engine
  2. Go to node_modules/@nguniversal/express-engine/package.json
  3. Add line "./schematics/utils": "./schematics/utils/index.js" to "exports"
  4. Run ng add @nestjs/ng-universal

Running Angular 14.0.5 , exact same error on my end

It seems that ng add will take some time to be sorted to enable it to configure @nestjs/ng-universal.

Before then; how do I install and configure @nestjs/ng-universal manually for @angular/cli@13.

Still having this issue. @sviat9440’s answer helped me get past the first bump. 🙂

Angular: 16.0.4 NX: 16.3.2 node: 18.15.0 npm: 9.5.0 pnpm: 8.2.0 @nestjs/ng-universal: 7.1.1

If I understood correctly then this issue should be soon resolved by @nguniversal\express-engine. This seems to be the fix: angular/universal#2491 and it is currently available as v13.1.0-next.1

as far as I understand, that is a different error

If I understood correctly then this issue should be soon resolved by @nguniversal\express-engine. This seems to be the fix: https://github.com/angular/universal/issues/2491 and it is currently available as v13.1.0-next.1

I’ve found that maybe the error is because of @nestjs/ng-universal v6.0.0 and I made the following tests:

Using @angular/cli@13 and then ng add @nestjs/ng-universal@6 produced the error. Using @angular/cli@12 and then ng add @nestjs/ng-universal@6 produced the error. Using @angular/cli@12 and then ng add @nestjs/ng-universal@5 had no error. Using @angular/cli@13 and then ng add @nestjs/ng-universal@5 had no error.

Maybe that will help.