Tuesday, 2 May 2017

import * as https from 'https' throws an error :https module not found angular2

I want to use node js https module in angular2.

I have run npm install https --save to download the module. After that whenever I try to import this module it is throwing an error saying https module doesn't exists.

But in my node_modules folder https exists and same goes for package.json

I am not able to figure out the root cause of this error.

Here is my code:

import * as https from 'https';
import { Component } from '@angular/core';
import * as firebase from 'firebase';
import {Observable} from "rxjs/Observable";
import * as firebaseKeys from '../lib/firebaseLibrary/firebaseKeys';
import { MdSnackBar,MdInputModule,MdButtonModule,MdCardModule, MdSnackBarConfig} from '@angular/material';
import { Msg91} from '../lib/networkingLibrary/msg91.service';

@Component({
  selector: 'login-element',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.css'],
  providers:[Msg91],
})

Here is my package.json:

{
  "name": "my-app",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^4.0.3",
    "@angular/common": "^4.0.0",
    "@angular/compiler": "^4.0.0",
    "@angular/core": "^4.0.0",
    "@angular/forms": "^4.0.0",
    "@angular/http": "^4.0.0",
    "@angular/material": "^2.0.0-beta.3",
    "@angular/platform-browser": "^4.0.0",
    "@angular/platform-browser-dynamic": "^4.0.0",
    "@angular/router": "^4.0.0",
    "angularfire2": "^4.0.0-rc0",
    "core-js": "^2.4.1",
    "firebase": "^3.9.0",
    "fs": "0.0.1-security",
    "hammerjs": "^2.0.8",
    "https": "^1.0.0",
    "path": "^0.12.7",
    "request": "^2.81.0",
    "rxjs": "^5.1.0",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular/cli": "1.0.1",
    "@angular/compiler-cli": "^4.0.0",
    "@types/jasmine": "2.5.38",
    "@types/node": "~6.0.60",
    "codelyzer": "~2.0.0",
    "jasmine-core": "~2.5.2",
    "jasmine-spec-reporter": "~3.2.0",
    "karma": "~1.4.1",
    "karma-chrome-launcher": "~2.0.0",
    "karma-cli": "~1.0.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "protractor": "~5.1.0",
    "ts-node": "~2.0.0",
    "tslint": "~4.5.0",
    "typescript": "~2.2.0"
  }
}



via mark922

No comments:

Post a Comment