Ionic Uncaught Error: Cannot find module "." when importing a service provider

KnowledgeSeeker

I am trying to import a new service provider that I just created after pulling from the latest branch in my ionic app.

When I try to import this line of code:

import { AuthServiceProvider } from '../providers/auth-service'

in app.module.ts I always got an error saying that:

Uncaught Error: Cannot find module "."
    at webpackMissingModule (index.js:3)
    at e.code (index.js:3)
    at Object.<anonymous> (index.js:9)
    at __webpack_require__ (bootstrap 62d6a5897825ac327001:54)
    at Object.690 (slide.transition.ts:67)
    at __webpack_require__ (bootstrap 62d6a5897825ac327001:54)
    at Object.495 (main.js:1885)
    at __webpack_require__ (bootstrap 62d6a5897825ac327001:54)
    at Object.487 (notification-api.ts:6)
    at __webpack_require__ (bootstrap 62d6a5897825ac327001:54)

But take note that I am also importing another service from my provider that is working perfectly.

Here is the code of my auth-service.ts below.

import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Events } from 'ionic-angular/umd';

/*
  Generated class for the AuthServiceProvider provider.

  See https://angular.io/guide/dependency-injection for more info on providers
  and Angular DI.
*/
@Injectable()
export class AuthServiceProvider {

  public isLoggedIn = false;

  constructor(
    public http: HttpClient,
    private events: Events
  ) {
    console.log('Hello AuthServiceProvider Provider');

    events.subscribe('user:logged-in', (user) => {
      this.isLoggedIn = true;
      console.log('Welcome', user);
    });
  }

}

I won't show my code in my app.module.ts because it is bombarded by import plugins and other providers.

Here is my ionic info

cli packages: (/usr/lib/node_modules)

@ionic/cli-utils  : 1.19.2
ionic (Ionic CLI) : 3.20.0

global packages:

cordova (Cordova CLI) : 8.0.0 

local packages:

@ionic/app-scripts : 3.1.8
Cordova Platforms  : android 6.3.0 browser 5.0.3
Ionic Framework    : ionic-angular 3.9.2

System:

Android SDK Tools : 26.1.1
Node              : v6.12.2
npm               : 4.6.1 
OS                : Linux 4.13

Environment Variables:

ANDROID_HOME : /home/clifford/Android/Sdk

So why I am having an error in that specific service provider compare to other providers which are just the same?

Any thoughts?

Appreciate if someone could help. Thanks in advance.

KnowledgeSeeker

I finally figure it out to solve the problem. The error occurs when I import the events from ionic-angular.

So instead of: import { Events } from 'ionic-angular/umd';

Just remove the umd at the end. I don't know why it happened because I am using auto import from my vs code.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Jest gives `Cannot find module` when importing components with absolute paths

Error when importing a module

Ionic 2 - Runtime error Cannot find module "."

Runtime Error Cannot find module "ionic-native" IONIC 2

Uncaught Error: Cannot Find Module When Using Dynamic Import for JavaScript

Uncaught Error: Cannot find module "fs" when using webpack

How can I resolve Ionic Uncaught Error: Cannot find module "." when adding new page?

Uncaught Error: Cannot find module 'stream'

Ionic3 - Uncaught Error: Cannot find module '.'

Error: "Cannot find module" when cloning Ionic 4 component with StencilJS

' Cannot find module './admin.service' when importing the admin.service.ts file in angular?

Ionic 4 / Angular Routing: ERROR Error: Uncaught (in promise): Error: Cannot find 'EventHomePageModule' in './home/home.module'

'Cannot find module fingerprintjs2' error when importing the library in Angular project

Cannot find module error when importing a module with exported enums

"Cannot find module" when importing .csv file in Create React App

Uncaught Error: Cannot find module 'redux'

Uncaught Error: Cannot find module "./RandomWords"

Meteor Error: Uncaught Error: Cannot find module 'component.jsx'

Uncaught Error: Cannot find module 'openpgp'

Cannot find module generated with “Ionic g provider”

Ionic => Runtime error: Cannot find module "."

Console error "Uncaught Error: Cannot find module "/axios" at webpackMissingModule" with react

Cannot find module when importing from project in python

Dynamic import components error - Uncaught (in promise) Error: Cannot find module

Error "Cannot find module" when importing a remote JSON file in TypeScript

Why I get "Uncaught Error: Cannot find module 'multi.js' " when module is installed globally?

"Cannot find module" error when importing mp3

Uncaught Error: Cannot find module 'firebase' when trying to use serverTimestamp in firestore

Uncaught Error: Cannot find module 'firebase'