Skip to content

Cannot find module 'forcejs'. while using angular 2 in ionic 2 #12

@KaushikRay

Description

@KaushikRay

I am working as a noob on my ionic 2 / ang 2 application. I am trying to set it up to use forcejs auth implementation.

Now I create a basic app following the ionic 2 tutorial here - http://ionicframework.com/docs/v2/getting-started/tutorial/

Now I am trying to integrate my force js implementation based on - http://coenraets.org/blog/2015/10/integrating-ecmascript-6-web-applications-with-salesforce-using-oauth-and-rest/

Now on app initialization I want to login using SF dev creds and Oauth.

I did a forcejs install using

npm install forcejs --save-dev

And in my app.ts file I am trying to import same. App.ts -

import {Component, ViewChild} from '@angular/core';
import {ionicBootstrap, Platform, MenuController, Nav} from 'ionic-angular';
import {StatusBar} from 'ionic-native';
import {HelloIonicPage} from './pages/hello-ionic/hello-ionic';
import {ListPage} from './pages/list/list';

//ERROR on this line - TypeScript error: app/app.ts(7,24): Error TS2307: Cannot find module 'forcejs'
// wbile doing a gulp build
import * as force from 'forcejs';


@Component({
  templateUrl: 'build/app.html'
})
class MyApp {
  @ViewChild(Nav) nav: Nav;

  // make HelloIonicPage the root (or first) page
  rootPage: any = HelloIonicPage;
  pages: Array<{title: string, component: any}>;

  constructor(
    private platform: Platform,
    private menu: MenuController
  ) {
    this.initializeApp();

    // set our app's pages
    this.pages = [
      { title: 'Hello Ionic', component: HelloIonicPage },
      { title: 'My First List', component: ListPage }
    ];
  }

  initializeApp() {
    this.platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.

      // Login in Salesforce using forcejs
      force.init({
          proxyURL: "https://dev-cors-proxy.herokuapp.com/"
      });

      force.login().then(() => {
          console.log("logged in");
      });

      StatusBar.styleDefault();
    });
  }

  openPage(page) {
    // close the menu when clicking a link from the menu
    this.menu.close();
    // navigate to the new page if it is not the current page
    this.nav.setRoot(page.component);
  }
}

ionicBootstrap(MyApp);

Now check top of the page for imports

TypeScript error: app/app.ts(7,24): Error TS2307: Cannot find module
'forcejs'

I can see forcejs under node_modules folder but not sure now how to import same.

Please help with same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions