简体   繁体   中英

Not taking reference from node_modules while creating angular 6 from VS-2017

I have created one angular 6 application using visual studio 2017. 在此处输入图片说明

Here is the screenshot for my visual studio project (Angular).

在此处输入图片说明

As you can see I have added one new component and service named as Todo . When I am adding todo.service.ts I need to add some references of angular modules so that I can avail HttpClient, HttpHeaders, HttpParams , catchError, tap, map features.

But here seems like I am not able to refer the path to the angular module package which we can easily refer while creating project using cli command because there we have node_modules folder where we have all packages and importing file using below command

import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; import { catchError, tap, map } from 'rxjs/operators';

but here in VS-2017 I am not able to refer the package. It give me an error like "can not find modules"

Here is the screen shot for the same.

在此处输入图片说明

Please suggest me what to do here how to refer to angular packages while creating angular project in VS-2017.

Note there is no error in referring to the package because the same code is working while creating project using angular CLI command.

Navigate to directory where package.json file is placed

Run

npm install

If still the issue persists

Install required package using npm:

npm i <package-name> --save

Do this , Replace /common/http to common only

Same for operators

I got the solution..

  1. You can rename or deleted the existing node_modules folder.
  2. Then create new project using angular-cli command.
  3. Then paste the copy the node_modules(step 2) to my .NET folder (step1).

Now, it start working.

Thanks for your all suggestion guys..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM