问题描述
限时送ChatGPT账号..未捕获的错误:找不到模块."
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 ee3a374a94c4cd74e2a6:54)
at Object.256 (main.ts:5)
at __webpack_require__ (bootstrap ee3a374a94c4cd74e2a6:54)
at Object.233 (main.js:412)
at __webpack_require__ (bootstrap ee3a374a94c4cd74e2a6:54)
at webpackJsonpCallback (bootstrap ee3a374a94c4cd74e2a6:25)
at main.js:1
在应用程序中添加新的 bookmarks
页面之前,应用程序运行良好,添加 bookmarks
页面后,我收到 未捕获的错误:找不到模块."
Before adding new bookmarks
pages in app, the app working perfectly fine, After adding bookmarks
pages i'm getting Uncaught Error: Cannot find module "."
这是我的设置
Ionic Framework: 3.9.2
Angular Core: 5.2.11
Angular Compiler CLI: 5.2.11
Node: 8.11.1
app.module.ts
import { ContactPage } from '../pages/contact/contact';
import { BookmarksPage} from'../pages/bookmarks/bookmarks';
@NgModule({
declarations: [
ContactPage,
BookmarksPage,
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
ContactPage,
BookmarksPage,
],
providers: [
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}
bookmarks.ts
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
@Component({
selector: 'page-bookmarks',
templateUrl: 'bookmarks.html'
})
export class BookmarksPage {
constructor(public navCtrl: NavController) {
}
}
开发者控制台中的 index.js
我也尝试清除缓存和 npm rebuild
.在构建 (ionic serve
) 过程中没有错误.但是在浏览器中我发现找不到模块,我真的很想了解这里发生了什么
I've tried to clear cache and npm rebuild
also.
In the build (ionic serve
) process there is no errors. But in the browser i'm getting Cannot find module, i really want to understand what is going on here
推荐答案
终于发现,当从 ionic cli
创建项目时,项目中缺少 IonicPageModule
.
Finally figured out, when creating the project from ionic cli
the IonicPageModule
was missing on the project.
在项目中手动添加 IonicPageModule
并运行命令 npm run-script
修复了问题.
Adding IonicPageModule
manually in project and running command npm run-script
fixed the issue.
解决方案
app-module.ts
import { IonicPageModule } from 'ionic-angular';
imports: [
IonicPageModule.forChild(HomePage)
],
npm run-script build
注意:IonicPageModule
是一个 NgModule
,它引导子 IonicPage
以设置路由.
NOTE: IonicPageModule
is an NgModule
that bootstraps a child IonicPage
in order to set up routing.
PS:仍然不知道那是如何工作的,但那是有效的.感谢大家的帮助.
PS: Still dint know how that worked, but that worked. Thanks everyone for trying to help.
这篇关于如何解决 Ionic Uncaught Error: 找不到模块“."添加新页面时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论