离子未捕获错误:找不到模块“。”导入服务提供商时 [英] Ionic Uncaught Error: Cannot find module "." when importing a service provider

查看:391
本文介绍了离子未捕获错误:找不到模块“。”导入服务提供商时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从我离子应用程序中的最新分支中提取后导入我刚创建的新服务提供程序。

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'

app.module.ts 我总是收到错误消息:

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.

以下是我的 auth-service.ts 的代码。

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);
    });
  }

}

我不会显示我的代码在我的 app.module.ts 中,因为它受到导入插件和其他提供商的轰炸。

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

这是我的离子信息

cli packages: (/usr/lib/node_modules)

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

全球包:

cordova (Cordova CLI) : 8.0.0 

本地套餐:

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

系统:

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

环境变量:

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?

有什么想法吗?

感谢有人可以提供帮助。
提前致谢。

Appreciate if someone could help. Thanks in advance.

推荐答案

我终于想通了解决这个问题。从 ionic-angular导入事件时发生错误

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

所以代替:从'ionic-angular / umd'导入{Events};

最后删除 umd 。我不知道为什么会发生这种情况,因为我正在使用来自我的vs代码的自动导入。

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

这篇关于离子未捕获错误:找不到模块“。”导入服务提供商时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆