【问题标题】:cannot find module “@angular/core/src/metadata/directives”找不到模块“@angular/core/src/metadata/directives”
【发布时间】:2018-06-30 08:24:38
【问题描述】:

我在尝试查看 Ionic2 应用程序时遇到此错误。我试图在我的应用程序中实现一个天气应用程序。我不确定这是否会导致错误。

我不确定错误来自哪里,所以我不确定要发布哪个代码,所以,如果您需要查看代码的某个部分,请告诉我。

找不到模块“@angular/core/src/metadata/directives”

import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import firebase from 'firebase';
import { firebaseConfig } from './credentials';
import { HomePage } from '../pages/home/home';
import { Unsubscribe } from '@firebase/util';
import {MenuPage} from '../pages/menu/menu';

@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  rootPage: any;

  constructor(
    platform: Platform,
    statusBar: StatusBar,
    splashScreen: SplashScreen
  ) {
    firebase.initializeApp(firebaseConfig);

    const unsubscribe: Unsubscribe = firebase.auth().onAuthStateChanged(user => {
      if (user) {
        this.rootPage = HomePage;
        unsubscribe();
      } else {
        this.rootPage = 'LoginPage';
        unsubscribe();
      }
    });

    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.
      statusBar.styleDefault();
      splashScreen.hide();
    });
  }
}

【问题讨论】:

  • 在问题中发布您的代码
  • 正如我所提到的,我不知道错误来自哪里,所以我不确定要发布代码的哪一部分,抱歉
  • @ukbount 发布您的 component.ts
  • hmm 有没有你在代码中使用@angular/core/src/metadata/directives 的地方?
  • 这个问题我也加了

标签: angularjs angular ionic-framework ionic2


【解决方案1】:

Deep imports 不支持,正如我在上面的评论中提到的,更改

来自

import {Input} from '@angular/core/src/metadata/directives';

收件人

 import {Input} from '@angular/core';

【讨论】:

  • 还是出现同样的错误,可能是在其他文件夹中使用
  • 仔细检查并重新启动
  • 重新启动应用程序?
  • npm 缓存清理然后 npm 启动
  • 它仍然显示我仍然不确定。感谢您的帮助
【解决方案2】:

将导入改为:

import {Input} from '@angular/core';

然后重新启动应用程序。

【讨论】:

    猜你喜欢
    • 2019-10-17
    • 1970-01-01
    • 2018-07-01
    • 2016-09-25
    • 1970-01-01
    • 1970-01-01
    • 2019-09-12
    • 2020-11-21
    • 2020-01-28
    相关资源
    最近更新 更多