taiga-family / ng-web-apis

A set of common utils for consuming Web APIs with Angular
https://taiga-family.github.io/ng-web-apis
Apache License 2.0
750 stars 42 forks source link

🐞 - Module not found: Error: Can't resolve 'perf_hooks' @ng-web-apis/universal on Angular 17 #525

Closed AmbroseNTK closed 2 months ago

AmbroseNTK commented 6 months ago

Playground Link

No response

Description

I am using @angular/ssr on Angular 17 with Taiga-ui 3.61.0 but it was error: TypeError: tinkoff_ng_dompurify_createDOMPurify is not a function

So that I used @ng-web-apis/universal according to this instruction: https://taiga-ui.dev/ssr but it was error: Can't resolve 'perf_hooks' @ng-web-apis/universal when I tried to build:ssr

Angular version

17.3.7

Taiga UI version

3.61.0

Which browsers have you used?

Which operating systems have you used?

waterplea commented 6 months ago

That's weird, it should be already available on pretty old nodejs versions. Your initial error though means you need to update @tinkoff/ng-dompurify and dompurify to latest versions.

shinkhouse commented 4 months ago

I am also having a similar issue with the perf_hooks.

✘ [ERROR] Could not resolve "node:perf_hooks"

node_modules/@ng-web-apis/universal/fesm2022/ng-web-apis-universal.mjs:243:17:
  243 │   return require('node:perf_hooks').performance;
      ╵                  ~~~~~~~~~~~~~~~~~

The package "node:perf_hooks" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

Angular CLI: 18.1.0 Node: 22.5.0 Package Manager: npm 10.8.2 OS: darwin arm64

Angular: 18.1.0 ... animations, cli, common, compiler, compiler-cli, core, forms ... language-service, localize, platform-browser ... platform-browser-dynamic, platform-server, router, ssr

Package Version

@angular-devkit/architect 0.1801.0 @angular-devkit/build-angular 18.1.0 @angular-devkit/core 18.1.0 @angular-devkit/schematics 18.1.0 @angular/cdk 18.1.1 @angular/material 18.1.1 @schematics/angular 18.1.0 rxjs 7.8.1 typescript 5.4.5 zone.js 0.14.4

I wonder if this has anything to do with new Angular builder.

splincode commented 4 months ago

@shinkhouse what is your version of Node.js?

shinkhouse commented 4 months ago

@shinkhouse what is your version of Node.js?

I am currently running on v20.13.1 but I also had this error come up with v22.5.0 and v18.20.4. I use NVM to switch between node versions.

splincode commented 4 months ago

what if you install the package

npm i --save-dev @types/node

do you have still an error?

splincode commented 2 months ago

Fixed