#angular common http has no exported member 'HttpContext'

13 messages · Page 1 of 1 (latest)

hallow tusk
#

I updated the API with the latest changes from the backend but keep getting an HttpContext error saying:

TS23305: Module ".../node_module/@angular/common/http" has no exported member 'HttpContext in all the files that it has been imported " import { HttpRequest, HttpParameterCodec, HttpParams, HttpHeaders, HttpContext } from '@angular/common/http'; "

outer sky
#

What does "updated the API" mean?

#

g!codeblock @hallow tusk What is the complete output of ng version? Please copy the text and paste it here in a code block.

viral monolithBOT
#

@hallow tusk, you can use the following snippet to have your code formatted and colored by Discord. Replace ts with the language you need (i.e. html, js, css, etc)
```ts
// your code goes here
```

hallow tusk
#

I'm sorry for that, with API I mean that I updated my openapiswagger.json by calling the command "ng-openapi-gen". For every file where I need to import HttpContext to be used, I keep getting: Module '"@angular/common/http"' has no exported member 'HttpContext'.ts(2305)

ng version

Angular CLI: 11.2.15
Node: 16.16.0
OS: win32 x64

Angular: 11.2.14
... animations, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1102.15
@angular-devkit/build-angular   0.1102.15
@angular-devkit/core            11.2.15
@angular-devkit/schematics      11.2.15
@angular/cdk                    11.2.13
@angular/cli                    11.2.15
@angular/material               11.2.3
@schematics/angular             11.2.15
@schematics/update              0.1102.15
rxjs                            6.6.7
typescript                      4.1.6
outer sky
#

Well I don't think that Angular v11 supports NodeJs v16. Let me check.

#

16.16.0 > 13.0.0 && 16.16.0 > 16.0.0
So I would suggest that you go down to NodeJS v12.

hallow tusk
#

I totally understand. I'll go from there, really appreciate your help!

outer sky
#

It is possible that your error will be resolved by using v12 of NodeJS and the bundled npm. Since NodeJS v16 changed how dependencies are installed, you likely will need to re-do the installation.

#

If you have a package-lock.json file from before it broke you could npm ci to "clean install" the lock file's dependencies exactly.

#

Otherwise you can delete the node_modules folder and the package-lock.json file and then run npm install. but that likely will install slightly different versions of your dependencies (and dependencies of your dependences, recurse) which might both fix problems and cause them 🙂

#

I like to use nvm to manage my node versions