Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Webpack type error with latest @types/node in Angular 18 #30265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task
Yogu opened this issue May 7, 2025 · 2 comments
Closed
1 task

Webpack type error with latest @types/node in Angular 18 #30265

Yogu opened this issue May 7, 2025 · 2 comments

Comments

@Yogu
Copy link

Yogu commented May 7, 2025

Command

build

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

Can we update to [email protected] in the 18.2.x branch? It fixes webpack/webpack#19498, which is a type error that is occuring since a recent @types/node version.

I saw that webpack was recently updated on main #30260, but 18.2.x is still using an older webpack version. Is it planned to update webpack on 18.2.x in this case to fix the type error?

Minimal Reproduction

I get the error when building a storybook app based on Angular 18.2. Please let me know if providing a reproduction is helpful, then I'll try to set up a public repro.

Exception or Error

node_modules/webpack/types.d.ts:14856:15 - error TS2417: Class static side 'typeof WebpackError' incorrectly extends base class static side '{ readonly prototype: Error; captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void; prepareStackTrace(err: Error, stackTraces: CallSite[]): any; stackTraceLimit: number; }'.
  Types of property 'prepareStackTrace' are incompatible.
    Type '((err: Error, stackTraces: CallSite[]) => any) | undefined' is not assignable to type '(err: Error, stackTraces: CallSite[]) => any'.
      Type 'undefined' is not assignable to type '(err: Error, stackTraces: CallSite[]) => any'.

14856 declare class WebpackError extends Error {
                    ~~~~~~~~~~~~

Your Environment

Angular CLI: 18.2.19
Node: 20.18.2
Package Manager: npm 10.8.2
OS: linux x64

Angular: 18.2.13
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1902.10
@angular-devkit/build-angular   18.2.19
@angular-devkit/core            19.2.10
@angular-devkit/schematics      18.2.19
@angular/cdk                    18.2.14
@angular/cli                    18.2.19
@angular/material               18.2.14
@schematics/angular             18.2.19
ng-packagr                      18.2.1
rxjs                            7.8.2
typescript                      5.4.5
zone.js                         0.14.10

Anything else relevant?

No response

@alan-agius4
Copy link
Collaborator

Although this error is caused by a third-party change and falls under the LTS policy, updating Webpack in an LTS release is considerably risky. Especially since there are safer alternatives. You can resolve the issue by enabling skipLibCheck, which is also the recommended approach by TypeScript, or by pinning the @types/node package.

Also, I'm not sure why Webpack is being included in your compilation generally, that shouldn't be the case.

@alan-agius4 alan-agius4 closed this as not planned Won't fix, can't repro, duplicate, stale May 7, 2025
@Yogu
Copy link
Author

Yogu commented May 7, 2025

Understandable, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants