EXCEPTION: Uncaught (in promise): Error: Cannot find module 'app/home/home.module'

sidali

I'm trying to lazy load Angular 2 modules with the router, and I'm having this error:

error_handler.js:50 EXCEPTION: Uncaught (in promise): Error: Cannot find module 'app/home/home.module'

I tried all the answers that seems to be working for the others, like this one which seems to be a solution for everybody facing this issue, but doesn't work with me Lazy loading in Angular2 RC7 and angular-cli webpack

here is my code:app.module

import { MediatorService } from './home/mediator.service';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';

import { AppComponent } from './app.component';


import appRoutes from "./app.routes";


@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    appRoutes
  ],
  providers: [MediatorService],
  bootstrap: [AppComponent]
})
export class AppModule { }

app.routes

import { RouterModule } from '@angular/router';

const routes = [
 {path : '', loadChildren: './home/home.module#HomeModule'},
 {path: 'devis', loadChildren: './forms/forms.module#FormsModule'}
];

export default RouterModule.forRoot(routes);

home.module

import {NgModule} from "@angular/core";
import {CommonModule} from "@angular/common";
import homeRoutes from "./home.routes";

@NgModule({
  imports:[CommonModule, homeRoutes],
  declarations: [HomeComponent]
})
export default class HomeModule{}

home.routes

import {RouterModule} from "@angular/router";
import {HomeComponent} from "./home.component";
const routes = [
  {path: '', component: HomeComponent}
];

export default RouterModule.forChild(routes);

Package.json

{
  "name": "insurance",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "lint": "tslint \"src/**/*.ts\"",
    "test": "ng test",
    "pree2e": "webdriver-manager update --standalone false --gecko false",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "^2.3.1",
    "@angular/compiler": "^2.3.1",
    "@angular/core": "^2.3.1",
    "@angular/forms": "^2.3.1",
    "@angular/http": "^2.3.1",
    "@angular/platform-browser": "^2.3.1",
    "@angular/platform-browser-dynamic": "^2.3.1",
    "@angular/router": "^3.3.1",
    "bootstrap": "^4.0.0-alpha.5",
    "core-js": "^2.4.1",
    "font-awesome": "^4.7.0",
    "rxjs": "^5.0.1",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.7.2"
   },
  "devDependencies": {
    "@angular/compiler-cli": "^2.3.1",
    "@types/jasmine": "2.5.38",
    "@types/jquery": "^2.0.34",
    "@types/node": "^6.0.42",
    "angular-cli": "1.0.0-beta.24",
    "codelyzer": "~2.0.0-beta.1",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "protractor": "~4.0.13",
    "ts-node": "1.2.1",
    "tslint": "^4.0.2",
    "typescript": "~2.0.3"
  }
}

UPDATE

I managed to make it work on plunker

https://plnkr.co/edit/uLxmxDIeCdDzxbFjYQS7?p=preview

but still nothing on my machine !!!!

UPDATE

I installed a new virtual machine ubuntu 16.04 and I have the same problem! Could it be because of the versions of the modules, I mean those on package.json? How can I find out the versions used in plunker because it worked on there.

sidali

I managed to make it work, here is what I done :

1 - Make the routing code in the module ( not a file )

2 - Make the module file in the parent directory of the component

3 - Delete the 'default' in the export like this

export DEFAULT class HomeModule { }

became

export class HomeModule { }

you can see that it works with beta 24 here : https://github.com/mauricedb/lazy-routes

I don't know what is happening !!!

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

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

From Dev

Routing module stop working: Uncaught (in promise): Error: Cannot find 'xxxModule'

From Dev

ERROR Error: Uncaught (in promise): Error: Cannot find module './user/user.module'

From Dev

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

From Dev

Uncaught Error: Cannot find module "./RandomWords"

From Dev

Uncaught Error: Cannot find module 'stream'

From Dev

Uncaught Error: Cannot find module 'redux'

From Dev

Uncaught Error: Cannot find module 'openpgp'

From Dev

Uncaught Error: Cannot find module 'firebase'

From Dev

Issue with jsPDF: Uncaught (in Promise) Error: Could not load dompurify: Error: cannot find module 'dompurify'

From Dev

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

From Dev

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

From Dev

Parcel 2 - Uncaught Error: Cannot find module 'axios'

From Dev

React and Docker - Uncaught Error: Cannot find module 'react-player'

From Dev

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

From Dev

Ionic3 - Uncaught Error: Cannot find module '.'

From Dev

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

From Dev

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

From Dev

Uncaught Error: Cannot find module './imgShop/X React

From Dev

Uncaught Error: Cannot find module './recipes' in React Native

From Dev

Error: Cannot find module './'

From Dev

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

From Dev

webpacker Uncaught Error: Module build failed / Cannot find module 'babel-plugin-syntax-dynamic-import'

From Dev

Error: Cannot find module 'transformer-module'

From Dev

error 'MODULE NOT FOUND', Cannot find module

From Dev

Cannot find module 'promise' when uploading to heroku

From Dev

Error: Cannot find module 'commander'

From Dev

Error: Cannot find module 'mongodb'

From Javascript

Error: Cannot find module html

Related Related

  1. 1

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

  2. 2

    Routing module stop working: Uncaught (in promise): Error: Cannot find 'xxxModule'

  3. 3

    ERROR Error: Uncaught (in promise): Error: Cannot find module './user/user.module'

  4. 4

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

  5. 5

    Uncaught Error: Cannot find module "./RandomWords"

  6. 6

    Uncaught Error: Cannot find module 'stream'

  7. 7

    Uncaught Error: Cannot find module 'redux'

  8. 8

    Uncaught Error: Cannot find module 'openpgp'

  9. 9

    Uncaught Error: Cannot find module 'firebase'

  10. 10

    Issue with jsPDF: Uncaught (in Promise) Error: Could not load dompurify: Error: cannot find module 'dompurify'

  11. 11

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

  12. 12

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

  13. 13

    Parcel 2 - Uncaught Error: Cannot find module 'axios'

  14. 14

    React and Docker - Uncaught Error: Cannot find module 'react-player'

  15. 15

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

  16. 16

    Ionic3 - Uncaught Error: Cannot find module '.'

  17. 17

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

  18. 18

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

  19. 19

    Uncaught Error: Cannot find module './imgShop/X React

  20. 20

    Uncaught Error: Cannot find module './recipes' in React Native

  21. 21

    Error: Cannot find module './'

  22. 22

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

  23. 23

    webpacker Uncaught Error: Module build failed / Cannot find module 'babel-plugin-syntax-dynamic-import'

  24. 24

    Error: Cannot find module 'transformer-module'

  25. 25

    error 'MODULE NOT FOUND', Cannot find module

  26. 26

    Cannot find module 'promise' when uploading to heroku

  27. 27

    Error: Cannot find module 'commander'

  28. 28

    Error: Cannot find module 'mongodb'

  29. 29

    Error: Cannot find module html

HotTag

Archive