6

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.

enter image description here

Any help would be appreciated.

8
  • Did you try to install npm packages? Commented Aug 26, 2016 at 6:03
  • Hello scokmen, not sure what you mean by that, but I followed the tutorial and installed NativeScript through NPM. So I guess the npm packages are installed, right? Commented Aug 26, 2016 at 9:30
  • 1
    In the root of your project run npm i? Commented Aug 26, 2016 at 9:39
  • Also, do you have a references file? Commented Aug 26, 2016 at 9:39
  • I tried this @GeorgeEdwards but it didn't do anything. Commented Aug 27, 2016 at 0:55

7 Answers 7

6

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.

Sign up to request clarification or add additional context in comments.

Comments

3

You include in file app.module.ts next "NativeScriptHttpModule" enter image description here

Comments

1

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"

1 Comment

Look into node_modules. With version 8, the name of package is changed so Change import { platformNativeScriptDynamic } from "nativescript-angular/platform"; to import { platformNativeScriptDynamic } from "@nativescript/angular"; I was migrating from V7 to V8 NativeScript
0

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.

Comments

0

Please upgrade your angular and nativescript to the current version; I can help you do that if you are stuck

Comments

0

In your component

import {HttpClient, HttpHeaders, HttpParams} from "@angular/common/http";

In app.module

import { NativeScriptHttpClientModule } from "nativescript-angular/http-client";
imports: [NativeScriptHttpClientModule]

Comments

-1

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

https://github.com/NativeScript/nativescript-angular/blob/master/nativescript-angular/http/ns-http.ts

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.