'Nativescript Cannot find module 'nativescript-angular/http'
I am following the NativeScript tutorial here:
Native Script Angular - Chapter 3
I'm having an error when trying to import nativescript-angular/http. it says Cannot find module 'nativescript-angular/http'. Am I missing anything? I noticed that there is not http.js under node_modules/native-script-angular/http.js.
Any help would be appreciated.
Solution 1:[1]
I am pretty sure that the version of Angular you are using are no longer support 'http' service, try to use 'http-client' instead.
import { NativeScriptHttpClientModule } from "nativescript-angular/http-client";
Or use Angular version 5 or older.
Solution 2:[2]
Solution 3:[3]
Trying to look for NativeScriptHttpClientModule was not quite enough to fix this for me. I additionally had to remove the '/http' from the end. It's able to find the module in the 'nativescript-angular' directory without the reference to the sub directory.
import { NativeScriptHttpClientModule } from "nativescript-angular"
Solution 4:[4]
I had a similar issue. All I had to do was to remove package-lock.json file along with my node_modules folder and npm install after that.
Solution 5:[5]
Please upgrade your angular and nativescript to the current version; I can help you do that if you are stuck
Solution 6:[6]
In your component
import {HttpClient, HttpHeaders, HttpParams} from "@angular/common/http";
In app.module
import { NativeScriptHttpClientModule } from "nativescript-angular/http-client";
imports: [NativeScriptHttpClientModule]
Solution 7:[7]
From within your groceries folder you just need to run the following commands to update the version.
$ npm install -g npm-check-updates
$ npm-check-updates -u
$ npm install
When package.json updated to the following it worked for me
"dependencies": {
"@angular/common": "2.0.0-rc.5",
"@angular/compiler": "2.0.0-rc.5",
"@angular/core": "2.0.0-rc.5",
"@angular/http": "2.0.0-rc.5",
"@angular/platform-browser": "2.0.0-rc.5",
"@angular/platform-browser-dynamic": "2.0.0-rc.5",
"@angular/platform-server": "2.0.0-rc.5",
"@angular/router": "3.0.0-rc.1",
"tns-core-modules": "2.2.1",
"nativescript-angular": "0.3.1"
},
If you compare the version you will see that NS _HTTP_PROVIDERS is within the current master but not version 2.0.0 that is included with the sample
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Astik Anand |
| Solution 3 | Ben McDonald |
| Solution 4 | Otacilio Oliveira |
| Solution 5 | John Wanjohi |
| Solution 6 | aditya_adi_98 |
| Solution 7 | Willem Engelbrecht |


