Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module '@angular/common/http/src/response after migrating to Angular 8 #30814

Closed
graphicsxp opened this issue Jun 3, 2019 · 27 comments

Comments

Projects
None yet
5 participants
@graphicsxp
Copy link

commented Jun 3, 2019

馃悶 bug report

Affected Package

The issue is caused by package @angular/common/http

Is this a regression?

Yes, the previous version in which this bug was not present was: angular 7.0

Description

after migrating to angular 8.0 using the command
ng update @angular/cli @angular/core
building the application using ng build --prod gives the following error:

error TS2307: Cannot find module '@angular/common/http/src/response'.

I use this for importing the HttpUploadProgressEvent interface 馃憤

import { HttpUploadProgressEvent } from '@angular/common/http/src/response';

Should I import it from else where ?

馃實 Your Environment

Angular Version: 8..0

Angular CLI: 8.0.1
Node: 12.3.1
OS: win32 x64
Angular: 8.0.0
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package Version

@angular-devkit/architect 0.800.1
@angular-devkit/build-angular 0.800.1
@angular-devkit/build-optimizer 0.800.1
@angular-devkit/build-webpack 0.800.1
@angular-devkit/core 8.0.1
@angular-devkit/schematics 8.0.1
@angular/cdk 7.3.3
@angular/cli 8.0.1
@ngtools/webpack 8.0.1
@schematics/angular 8.0.1
@schematics/update 0.800.1
rxjs 6.5.2
typescript 3.4.5
webpack 4.30.0

@graphicsxp graphicsxp changed the title Cannot find module '@angular/common/http/src/response Cannot find module '@angular/common/http/src/response after migrating to Angular 8 Jun 3, 2019

@sod

This comment has been minimized.

Copy link

commented Jun 3, 2019

Try @angular/common/http. I'm pretty sure you have to always import from the barrels, aka @angular/common/http ... never from src files, as that is considered private and can change any time.

@sod

This comment has been minimized.

Copy link

commented Jun 3, 2019

Hm, seems like it's not part of the public api https://github.com/angular/angular/blob/f8096d499324cf0961f092944bbaedd05364eea1/packages/common/http/public_api.ts, even though HttpDownloadProgressEvent is, but HttpUploadProgressEvent isn't. Maybe it was forgotten?

@graphicsxp

This comment has been minimized.

Copy link
Author

commented Jun 3, 2019

Yes, even if I import it from @angular/common/http, the compiler complains. I believe indeed this is a bug ?

@gkalpak

This comment has been minimized.

Copy link
Member

commented Jun 3, 2019

This seems indeed to be an unintentional omission in 37797e2. HttpUploadProgressEvent should be added to the public API here (as @sod mentioned above) and also add the @pablicApi annotation here (similar to HttpDownloadProgressEvent), so that it shows up in the docs.

In any case, you should never import from @angular/<package/entrypoint>/src/.... Everything that should be publicly importable, should be part of the public API.

@santoshyadav198613

This comment has been minimized.

Copy link
Contributor

commented Jun 4, 2019

Hi @gkalpak ,
Can i work on this.

santoshyadav198613 added a commit to santoshyadav198613/angular that referenced this issue Jun 4, 2019

@santoshyadav198613

This comment has been minimized.

Copy link
Contributor

commented Jun 4, 2019

Hi @gkalpak ,
Open for review.

@danrevah danrevah referenced this issue Jun 4, 2019

Closed

fix(common): expose upload progress event #30856

3 of 14 tasks complete

santoshyadav198613 added a commit to santoshyadav198613/angular that referenced this issue Jun 4, 2019

santoshyadav198613 added a commit to santoshyadav198613/angular that referenced this issue Jun 4, 2019

santoshyadav198613 added a commit to santoshyadav198613/angular that referenced this issue Jun 5, 2019

@mhevery mhevery closed this in 5c18f23 Jun 7, 2019

mhevery added a commit that referenced this issue Jun 7, 2019

@snahmad

This comment has been minimized.

Copy link

commented Jul 11, 2019

Is this resolved.

I tried

import { HttpUploadProgressEvent } from '@angular/common/http/src/response';

I update my angular to version=8
Still I get this error.

ERROR in node_modules/ngx-restangular/lib/ngx-restangular-http.d.ts(3,27): error TS2307: Cannot find module '@angular/common/http/src/response'.
src/app/app.module.ts(15,41): error TS2307: Cannot find module '@angular/common/http/src/response'.

@santoshyadav198613

This comment has been minimized.

Copy link
Contributor

commented Jul 11, 2019

Hi @snahmad ,
Which version you are using I can see it is available in 8.0.1.

@snahmad

This comment has been minimized.

Copy link

commented Jul 11, 2019

Angular CLI: 8.1.1
Node: 10.16.0
OS: win32 x64
Angular: 8.0.2
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package Version

@angular-devkit/architect 0.800.3
@angular-devkit/build-angular 0.800.3
@angular-devkit/build-optimizer 0.800.3
@angular-devkit/build-webpack 0.800.3
@angular-devkit/core 8.0.3
@angular-devkit/schematics 8.1.1
@angular/cdk 8.0.1
@angular/cli 8.1.1
@angular/flex-layout 8.0.0-beta.26
@angular/http 7.2.15
@angular/material 8.0.1
@ngtools/webpack 8.0.3
@schematics/angular 8.1.1
@schematics/update 0.801.1
rxjs 6.5.2
typescript 3.4.5
webpack 4.30.0

@santoshyadav198613

This comment has been minimized.

Copy link
Contributor

commented Jul 11, 2019

It is available in the version you mentioned, maybe do a clean install and check. https://github.com/angular/angular/blob/8.0.2/packages/common/http/src/response.ts

@snahmad

This comment has been minimized.

Copy link

commented Jul 11, 2019

no success.

I tried delete my node_modules.
npm install.

Still getting error:
ERROR in node_modules/ngx-restangular/lib/ngx-restangular-http.d.ts(3,27): error TS2307: Cannot find module '@angular/common/http/src/response'.

@gkalpak

This comment has been minimized.

Copy link
Member

commented Jul 11, 2019

@snahmad, you should be importing it from @angular/common/http now (not @angular/common/http/src/response).

@santoshyadav198613

This comment has been minimized.

Copy link
Contributor

commented Jul 11, 2019

Ohh sorry @snahmad my bad, yes it should be imported as @gkalpak said.

@snahmad

This comment has been minimized.

Copy link

commented Jul 11, 2019

What you mean. not clear to me. Kindly elaborate.

@santoshyadav198613

This comment has been minimized.

Copy link
Contributor

commented Jul 11, 2019

Hi @snahmad ,
Sorry it was my fault, the actual issue is you are using ngx-restangular which is still not updated to Angular 8. If you want you can take this and help them update or log an issue.

Here is the link for rep https://github.com/2muchcoffeecom/ngx-restangular.

@snahmad

This comment has been minimized.

Copy link

commented Jul 11, 2019

ok, Thanks, I have wait for ngx-restangular to be updated for angular 8. I need fix in few days. I guess either revert back to angular 6 or 7 or use HttpClient instead of ngx-restangular

@santoshyadav198613

This comment has been minimized.

Copy link
Contributor

commented Jul 12, 2019

ok, Thanks, I have wait for ngx-restangular to be updated for angular 8. I need fix in few days. I guess either revert back to angular 6 or 7 or use HttpClient instead of ngx-restangular

Moving to Angular Package will be a better idea in that case.

@snahmad

This comment has been minimized.

Copy link

commented Jul 12, 2019

What you mean by
Moving to Angular Package will be a better idea in that case?

@santoshyadav198613

This comment has been minimized.

Copy link
Contributor

commented Jul 12, 2019

What you mean by
Moving to Angular Package will be a better idea in that case?

I was just referring to your comment, where you said "use HttpClient instead of ngx-restangular"

@snahmad

This comment has been minimized.

Copy link

commented Jul 12, 2019

ok, HttpClient is official angular package,

https://angular.io/api/common/http.

Let me try to change from ngx-restangular to HttpClient.

Only issue will be change RestangularConfigFactory to use HttpClient.

// Function for settting the default restangular configuration
export function RestangularConfigFactory (RestangularProvider, router) {

 // by each request to the server receive a token and update headers with it

RestangularProvider.addFullRequestInterceptor((element, operation, path, url, headers, params) => {
console.log("addFullRequestInterceptor(operation='" + operation + "', path='" + path + "'") ;

let bearerToken = "";
let token = localStorage.getItem("token");
if (token) {
  bearerToken = token;
}
return {
    headers: Object.assign({}, headers, {Authorization: `mgs ${bearerToken}`})
};

});

RestangularProvider.addErrorInterceptor((response, subject, responseHandler) => {
if (response.status != 0) {
router.navigate(['error']);
return false; // error handled
} else {
return true;
}

});

@snahmad

This comment has been minimized.

Copy link

commented Jul 12, 2019

I am using all these three.

import {RestangularModule, Restangular} from 'ngx-restangular';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Http, Response, RequestOptions, ResponseContentType } from '@angular/http';
import { Observable } from 'rxjs/Observable';

I guess I can only use HttpClient to do everything.

Currently doing

getLogSubFiles(folder_name) : Observable<LogFile[]> {
return this.restangular.all('log_files').post({folder: folder_name});
}

I guess I can use HttpClient here instead of restangular

@santoshyadav198613

This comment has been minimized.

Copy link
Contributor

commented Jul 12, 2019

Yes @snahmad ,
You can if you need any help in migrating please post on stackoverflow or our gitter channel thanks.

@snahmad

This comment has been minimized.

Copy link

commented Jul 12, 2019

Yes @snahmad ,
You can if you need any help in migrating please post on stackoverflow or our gitter channel thanks.

Sure, Thanks. for now Try to fix using ngx-restangular. they claim they have fixed it for angular 8.

@snahmad

This comment has been minimized.

Copy link

commented Jul 17, 2019

I need help in moving from ngx-restangular to HttpClient. ngx-restangular is broken for latest angular.
Where to ask steps migrate from ngx-restangular to HttpClient

@santoshyadav198613

This comment has been minimized.

Copy link
Contributor

commented Jul 17, 2019

I need help in moving from ngx-restangular to HttpClient. ngx-restangular is broken for latest angular.
Where to ask steps migrate from ngx-restangular to HttpClient

StackOverflow with Angular Tag.

@snahmad

This comment has been minimized.

Copy link

commented Jul 17, 2019

ok, sure. Can I hire you or some one. I am runout of time. it is big change.

@santoshyadav198613

This comment has been minimized.

Copy link
Contributor

commented Jul 17, 2019

ok, sure. Can I hire you or some one. I am runout of time. it is big change.

That's you call, please feel free to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can鈥檛 perform that action at this time.