Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Error Module not found: Error: Can't resolve './app.module.ngfactory' #233

Closed
joey0xx opened this issue Jul 21, 2017 · 22 comments
Closed

Error Module not found: Error: Can't resolve './app.module.ngfactory' #233

joey0xx opened this issue Jul 21, 2017 · 22 comments

Comments

@joey0xx
Copy link

joey0xx commented Jul 21, 2017

Hi, im getting the following error when running webpack in my project:

Running webpack for android...
 10% building modules 2/4 modules 2 active ...ations\app\vendor-platform.android.ts(node:6196) DeprecationWarning: loaderUtils.pa
rseQuery() received a non-string value which can be problematic, see https://github.com/webpack/loader-utils/issues/56
parseQuery() will be replaced with getOptions( 40% building modules 258/259 modules 1 active ...Documents\HMM\medications\app\app
.css(node:6196) DeprecationWarning: Chunk.modules is deprecated. Use Chunk.getNumberOfModules/mapModules/forEachModule/containsMo
dule instead.                             Hash: 33401210a4aea07efaf3
Version: webpack 3.0.0
Time: 6308ms
                                       Asset       Size  Chunks                    Chunk Names
           images/icons/arrow-down-white.png  595 bytes          [emitted]
                                   bundle.js  887 bytes       0  [emitted]         bundle
                                   vendor.js       3 MB       2  [emitted]  [big]  vendor
                                     app.css    15.9 kB       1  [emitted]         app.css
               fonts/fontawesome-webfont.ttf     166 kB          [emitted]
                            images/amoxi.jpg    37.7 kB          [emitted]
                            images/_lock.png    1.87 kB          [emitted]
                                images/c.png    12.4 kB          [emitted]
                        images/hamburger.png  114 bytes          [emitted]
                          images/details.png       2 kB          [emitted]
                             images/book.png    4.36 kB          [emitted]
                            images/email.png    4.45 kB          [emitted]
                            images/clock.png    9.98 kB          [emitted]
       images/ic_help_outline_white_24dp.png  387 bytes          [emitted]
                         images/calendar.png    3.35 kB          [emitted]
                            images/heart.png    8.66 kB          [emitted]
             images/ic_search_black_24dp.png  390 bytes          [emitted]
        images/ic_description_white_48dp.png    1.88 kB          [emitted]
          images/ic_add_alert_white_48dp.png    3.31 kB          [emitted]
            images/ic_add_box_white_48dp.png    1.66 kB          [emitted]
               images/ic_help_white_48dp.png    6.46 kB          [emitted]
                  images/icons/001-stats.png    2.82 kB          [emitted]
       images/ic_help_outline_white_48dp.png    9.02 kB          [emitted]
                 images/icons/002-tablet.png    3.69 kB          [emitted]
                   images/icons/003-pill.png    3.04 kB          [emitted]
                  images/icons/004-pills.png    5.25 kB          [emitted]
                images/icons/005-notepad.png    2.92 kB          [emitted]
           images/icons/006-prescription.png    1.86 kB          [emitted]
                   images/icons/007-list.png     2.4 kB          [emitted]
                images/icons/009-history.png    2.78 kB          [emitted]
               images/icons/013-blue-add.png  403 bytes          [emitted]
             images/icons/010-blue-arrow.png  736 bytes          [emitted]
         images/icons/014-blue-substract.png  371 bytes          [emitted]
            images/icons/011-black-arrow.png  602 bytes          [emitted]
        images/icons/012-down-blue-arrow.png  655 bytes          [emitted]
                  images/icons/008-listp.png     3.2 kB          [emitted]
                 images/icons/addcontact.png    1.59 kB          [emitted]
                   images/icons/blue-dot.png  449 bytes          [emitted]
images/icons/arrow-down-sign-to-navigate.png  611 bytes          [emitted]
                     images/icons/agenda.png    4.83 kB          [emitted]
                                  app.css.js  269 bytes       1  [emitted]         app.css
                   images/icons/calendar.png    1.49 kB          [emitted]
                 images/icons/clock-gray.png  817 bytes          [emitted]
                  images/icons/bell-gray.png    2.39 kB          [emitted]
         images/icons/consulting-message.png    1.97 kB          [emitted]
                images/icons/doctor-gray.png    3.52 kB          [emitted]
                     images/icons/doctor.png    2.14 kB          [emitted]
                      images/icons/email.png    1.34 kB          [emitted]
                   images/icons/envelope.png    1.18 kB          [emitted]
                     images/icons/friend.png    5.43 kB          [emitted]
                      images/icons/group.png     2.6 kB          [emitted]
images/icons/keyboard-right-arrow-button.png  910 bytes          [emitted]
                    images/icons/man (2).png    2.69 kB          [emitted]
         images/icons/pencil-edit-button.png  988 bytes          [emitted]
  images/icons/multiple-users-silhouette.png    1.92 kB          [emitted]
                     images/icons/phone3.png    1.33 kB          [emitted]
                      images/icons/phone.png    1.38 kB          [emitted]
                  images/icons/time-gray.png    2.23 kB          [emitted]
                    images/icons/profile.png     4.6 kB          [emitted]
                       images/icons/team.png    2.17 kB          [emitted]
                            images/login.png  611 bytes          [emitted]
                     images/medical-pill.png  584 bytes          [emitted]
                  images/icons/pillcolor.png    3.61 kB          [emitted]
                       images/icons/user.png    1.93 kB          [emitted]
                 images/icons/user-shape.png  877 bytes          [emitted]
                         images/location.png    7.86 kB          [emitted]
                         images/notdrink.png    15.5 kB          [emitted]
           images/logo-triple-s-salud-en.png    52.3 kB          [emitted]
                              images/med.png  867 bytes          [emitted]
                             images/pill.png    7.12 kB          [emitted]
                       images/medication.png  704 bytes          [emitted]
                            images/pills.png      18 kB          [emitted]
                     images/prescription.png    4.71 kB          [emitted]
                         images/settings.png    1.38 kB          [emitted]
                           images/search.png    13.4 kB          [emitted]
                            images/sleep.png    16.8 kB          [emitted]
                              images/wal.png    17.2 kB          [emitted]
                                images/w.png      21 kB          [emitted]
                                package.json   82 bytes          [emitted]
                                  starter.js   39 bytes          [emitted]
                         tns-java-classes.js    0 bytes          [emitted]
 [110] .. lazy 160 bytes {2} [built]
 [158] ./main.aot.ts 471 bytes {0} [built]
 [202] ./vendor.ts 405 bytes {2} [built]
 [203] ./vendor-platform.android.ts 460 bytes {2} [built]
 [255] ./app.css 41 bytes {1} [built]
    + 253 hidden modules

ERROR in ENOENT: no such file or directory, open 'C:\Users\MyName\Documents\HMM\medications\app\components\shared-components\compo
nents\shared-components\login.component.android.html'

ERROR in ./main.aot.ts
Module not found: Error: Can't resolve './app.module.ngfactory' in 'C:\Users\Angel\Documents\HMM\medications\app'
 @ ./main.aot.ts 5:29-62
Child extract-text-webpack-plugin:
       [1] ../node_modules/resolve-url-loader?{"silent":true,"absolute":false,"sourceMap":false,"fail":false,"keepQuery":false,"d
ebug":false,"root":null}!../node_modules/nativescript-css-loader?{"minimize":false}!../node_modules/nativescript-dev-webpack/plat
form-css-loader.js!./app.css 2.52 kB {0} [built]
        + 2 hidden modules
Webpack Bundle Analyzer saved stats file to C:\Users\Angel\Documents\HMM\medications\report\stats.json
Webpack Bundle Analyzer saved report to C:\Users\Angel\Documents\HMM\medications\report\report.html
child process exited with code 2
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] ns-bundle: `ns-bundle`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] ns-bundle script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Angel\AppData\Roaming\npm-cache\_logs\2017-07-21T18_33_46_191Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] start-android-bundle: `npm run ns-bundle --android --run-app`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] start-android-bundle script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Angel\AppData\Roaming\npm-cache\_logs\2017-07-21T18_33_46_215Z-debug.log

@YvesCandel
Copy link

Suddenly got this error too since today, our CI build started failing without changing anything regarding dependencies.

@YvesCandel
Copy link

The issue seems to be within the "webpack" package. If I go to node_modules/webpack/package.json and remove all the ^ and ~ from the dependencies and reinstall the webpack/node_modules folder, the build works again...

@danielgek
Copy link

@jibon57 see the comment above

@YvesCandel
Copy link

It's not a sustainable solution for our build server though. Would like to dig up the package that's screwing things up and get a good fix for it.

@joey0xx
Copy link
Author

joey0xx commented Jul 24, 2017

I was having another issue with webpack which got resolved by removing the ^ and ~ from the dependencies but now I'm having this issue I posted. I think it has to do with the fact that the project was created before NS having AOT. I manually added the main.aot.ts file but im getting this error.

@ghost
Copy link

ghost commented Jul 24, 2017

I'm also getting this error, so I tried to reproduce it with a new project, which I created with tns create new-project --ng and afterwards I installed the nativescript-dev-webpack dependency. Then I ran npm run build-android-bundle and got this exact error.
Since this didn't happen a week ago, and I'm using --save-exact dependencies in my own project, I'm assuming this is caused by one of the sub-modules installed by the main dependencies. I can't figure which one though, since I deleted my old working node_modules directory.
I'm using Windows 10 64-bit, npm 4.6.1 and node 6.11.1 just in case it helps.

EDIT: Found which module was causing the issue. The new version of enhanced-resolve came out about 11 hours ago, just install version 3.3.0 and this issue will be solved while a bugfix comes out. Related issue: webpack/enhanced-resolve#98

@iguissouma
Copy link

I'm also getting this error.

@YvesCandel
Copy link

YvesCandel commented Jul 25, 2017

Updating @ngtools/webpack from 1.5.2 to 1.5.3 fixed the issue for us.

@vakrilov
Copy link
Contributor

vakrilov commented Jul 26, 2017

Setting exact version for enhanced-resolve("enhanced-resolve": "3.3.0") worked for me! Thanks @AxelZaraki

@joey0xx
Copy link
Author

joey0xx commented Aug 4, 2017

None of the solutions posted here have worked for me. I also tried doing what is suggested in these issues: nativescript-dev-webpack/issues/75, nativescript-dev-webpack/issues/36 , but no luck

@joey0xx
Copy link
Author

joey0xx commented Aug 4, 2017

When I followed the second comment in this issue: nativescript-dev-webpack/issues/36, im getting this error:

C:\Users\Angel\Documents\HMM\medications>npm run ngc -- -p tsconfig.aot.json

> [email protected] ngc C:\Users\Angel\Documents\HMM\medications
> ngc "-p" "tsconfig.aot.json"

Error: Compilation failed. Resource file not found: C:/Users/Angel/Documents/HMM/medications/app/components/shared-components/components/shared-components/login.component.html
    at ModuleResolutionHostAdapter.readResource (C:\Users\Angel\Documents\HMM\medications\node_modules\@angular\compiler-cli\src\compiler_host.js:370:19)
    at CompilerHost.loadResource (C:\Users\Angel\Documents\HMM\medications\node_modules\@angular\compiler-cli\src\compiler_host.js:243:85)
    at Object.get (C:\Users\Angel\Documents\HMM\medications\node_modules\@angular\compiler\bundles\compiler.umd.js:24640:107)
    at DirectiveNormalizer._fetch (C:\Users\Angel\Documents\HMM\medications\node_modules\@angular\compiler\bundles\compiler.umd.js:13297:45)
    at DirectiveNormalizer.normalizeTemplateAsync (C:\Users\Angel\Documents\HMM\medications\node_modules\@angular\compiler\bundles\compiler.umd.js:13352:21)
    at DirectiveNormalizer.normalizeTemplate (C:\Users\Angel\Documents\HMM\medications\node_modules\@angular\compiler\bundles\compiler.umd.js:13324:44)
    at CompileMetadataResolver._loadDirectiveMetadata (C:\Users\Angel\Documents\HMM\medications\node_modules\@angular\compiler\bundles\compiler.umd.js:14255:75)
    at C:\Users\Angel\Documents\HMM\medications\node_modules\@angular\compiler\bundles\compiler.umd.js:14451:54
    at Array.forEach (native)
    at CompileMetadataResolver.loadNgModuleDirectiveAndPipeMetadata (C:\Users\Angel\Documents\HMM\medications\node_modules\@angular\compiler\bundles\compiler.umd.js:14450:41)
Compilation failed
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] ngc: `ngc "-p" "tsconfig.aot.json"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] ngc script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Angel\AppData\Roaming\npm-cache\_logs\2017-08-04T15_35_15_289Z-debug.log

@joey0xx
Copy link
Author

joey0xx commented Aug 4, 2017

The error I just posted helped me determine that I had to have a module id on my components and had to change the paths of the templateUrls and styleUrl to a relative path. Just like the answer in this stackoverflow post: ngc-looking-in-wrong-directory

@anuragd7
Copy link

anuragd7 commented Aug 7, 2017

Hi @joey0xx ,
Were you able to fix this? Iam having a similar issue. See below. Thanks

@anuragd7
Copy link

anuragd7 commented Aug 7, 2017

Hi,
I have angular2 Nativescript project where I have implemented lazy loading. I am now trying to implement webpack with AOT as per the directions given by nativescript - here.
Accordingly, I installed the plugin : nativescript-dev-webpack and @ngtools/webpack.

Now when I run, npm run start-android-bundle, I get the following error:

ERROR in Could not resolve module @ angular/core

ERROR in ./main.aot.ts
Module not found: Error: Can't resolve './app.module.ngfactory' in 'C:\Users\krithika\MyProjects\questNewS\app'
@ ./main.aot.ts 3:0-60
Child extract-text-webpack-plugin C:\Users\krithika\MyProjects\questNewS\node_modules\extract-text-webpack-plugin\dist C:\Users\krithika\MyProjects\questNewS\node_modules\resolve-url-loader\index.js??ref--1-1!C:\Users\krithika\MyProjects\questNewS\node_modules\nativescript-css-loader\index.js??ref--1-2!C:\Users\krithika\MyProjects\questNewS\node_modules\nativescript-dev-webpack\platform-css-loader.js!C:\Users\krithika\MyProjects\questNewS\app\app.css:
[1] ../node_modules/resolve-url-loader?{"silent":true,"absolute":false,"sourceMap":false,"fail":false,"keepQuery":false,"debug":false,"root":null,"includeRoot":false}!../node_modules/nativescript-css-loader?{"minimize":false}!../node_modules/nativescript-dev-webpack/platform-css-loader.js!./app.css 925 bytes {0} [built]
+ 2 hidden modules
Webpack Bundle Analyzer saved stats file to C:\Users\krithika\MyProjects\questNewS\report\stats.json
Webpack Bundle Analyzer saved report to C:\Users\krithika\MyProjects\questNewS\report\report.html
child process exited with code 2

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Users\krithika\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "run" "ns-bundle" "--android" "--build-app"
npm ERR! node v6.9.5
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! @ ns-bundle: ns-bundle
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the @ ns-bundle script 'ns-bundle'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ns-bundle
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\krithika\MyProjects\questNewS\npm-debug.log

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Users\krithika\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "run" "build-android-bundle"
npm ERR! node v6.9.5
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! @ build-android-bundle: npm run ns-bundle --android --build-app
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ build-android-bundle script 'npm run ns-bundle --android --build-app'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run ns-bundle --android --build-app
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\krithika\MyProjects\questNewS\npm-debug.log

Also, in my code I find that the ts file gives me an error saying "cannot find module @angular/core". Similar errors are occuring for "ui/page" and "rxjs/Rx"

I have done the following things to fix this problem with no success -

  1. removed node_modules, hooks and platforms and added them again
  2. changed "enhanced-resolve" to 3.3.0
  3. changed the templates and style references to relative paths

Please suggest what I could to try and make webpack work in my project.

@iguissouma
Copy link

npm i [email protected] should solve the problem.

@jibon57
Copy link

jibon57 commented Aug 7, 2017

@iguissouma , I have tried it but still no luck :(

ERROR in Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 19:49 in the original .ts file), resolving symbol appRoutes in D:/Others/Documents/My_Work/NativeScript/app/routing.ts, resolving symbol routing in D:/Others/Documents/My_Work/NativeScript/app/routing.ts, resolving symbol routing in D:/Others/Documents/My_Work/NativeScript/app/routing.ts, resolving symbol AppModule in D:/Others/Documents/My_Work/NativeScript/app/app.module.ts, resolving symbol AppModule in D:/Others/Documents/My_Work/NativeScript/app/app.module.ts

ERROR in ./main.aot.ts
Module not found: Error: Can't resolve './app.module.ngfactory' in 'D:\Others\Documents\My_Work\NativeScript\app'
 @ ./main.aot.ts 4:29-62

#231

@iguissouma
Copy link

@jibon57 can you include your app.module.ts, it seems that something is not supported with aot compilation?

@jibon57
Copy link

jibon57 commented Aug 8, 2017

@iguissouma

app.module.ts

import { NgModule, NO_ERRORS_SCHEMA, NgModuleFactoryLoader } from "@angular/core";
import { NativeScriptHttpModule } from "nativescript-angular/http";
import { NativeScriptModule } from "nativescript-angular/nativescript.module";
import { NativeScriptRouterModule } from "nativescript-angular/router";
import { SlidesModule } from 'nativescript-ngx-slides';
import { NativeScriptUISideDrawerModule } from "nativescript-telerik-ui/sidedrawer/angular";

import { DropDownModule } from "nativescript-drop-down/angular";

import { AppComponent } from "./app.component";
import { CommonService } from "./services/commonServices"
import { GetJoomlaServer } from "./services/getJoomlaServer"
import { GetMoodleServer } from "./services/getMoodleServer"
import { routing } from './routing';
import { NsModuleFactoryLoader } from "./ns-module-factory-loader";

import { HomeComponent } from "./components/home/home";
import { DashboardComponent } from "./components/dashboard/dashboard";
import { MenuComponent } from "./components/shared/menu/menu";
import { MyCoursesComponent } from "./components/mycourses/mycourses"

@NgModule({
  declarations: [AppComponent, HomeComponent, MenuComponent, DashboardComponent, MyCoursesComponent],
  bootstrap: [AppComponent],
  imports: [
    NativeScriptModule, NativeScriptRouterModule, NativeScriptHttpModule, NativeScriptUISideDrawerModule,
    routing, SlidesModule, DropDownModule
  ],
  schemas: [NO_ERRORS_SCHEMA],
  providers: [{ provide: NgModuleFactoryLoader, useClass: NsModuleFactoryLoader }, CommonService, GetJoomlaServer, GetMoodleServer]
})
export class AppModule { }

routing.ts

import { NativeScriptRouterModule } from "nativescript-angular/router";

import { HomeComponent } from "./components/home/home";
import { DashboardComponent } from "./components/dashboard/dashboard";
import { MenuComponent } from "./components/shared/menu/menu";
import { MyCoursesComponent } from "./components/mycourses/mycourses"

export const appRoutes = [
  { path: "", name: 'Home', component: HomeComponent, hidden: 0, login: 1, logout: 1 },
  { path: "dashboard", name: 'Dashboard', component: DashboardComponent, hidden: 0, login: 1, logout: 1 },
  { name: "About", path: "about", loadChildren: () => require("./components/about/about.module#AboutModule"), hidden: 0, login: 1, logout: 1 },
  { name: "Blog", path: "blog", loadChildren: () => require("./components/blog/blog.module#BlogModule"), hidden: 0, login: 1, logout: 1 },
  { name: "Forum", path: "forum", loadChildren: () => require("./components/forum/forum.module#ForumModule"), hidden: 0, login: 1, logout: 1 },
  { name: "Course Market", path: "product", loadChildren: () => require("./components/product/product.module#ProductModule"), hidden: 0, login: 1, logout: 1 },
  { path: "mycourses", name: 'My Courses', component: MyCoursesComponent, hidden: 0, login: 1, logout: 0 },
  { name: "Login/Register", path: "login", loadChildren: () => require("./components/login/login.module#LoginModule"), hidden: 0, login: 0, logout: 1 },
  { name: "Logout", path: "logout", loadChildren: () => require("./components/logout/logout.module#LogoutModule"), hidden: 0, login: 1, logout: 0 },
  { path: "coursedetails", name: 'Course Items', loadChildren: () => require("./components/coursedetails/coursedetails.module#CourseModule"), hidden: 1 },
  { path: "page", name: 'Page', loadChildren: () => require("./components/coursemodules/page/page.module#PageModule"), hidden: 1 },
  { path: "glossary", name: 'Glossary', loadChildren: () => require("./components/coursemodules/glossary/glossary.module#GlossaryModule"), hidden: 1 },
  { path: "jibon", name: 'Jibon', loadChildren: () => require("./components/coursemodules/jibon/jibon.module#JibonModule"), hidden: 1 },
  { path: "dubbing", name: 'Dubbing', loadChildren: () => require("./components/coursemodules/dubbing/dubbing.module#DubbingModule"), hidden: 1 },
  { path: "quiz", name: 'Quiz', loadChildren: () => require("./components/coursemodules/quiz/quiz.module#QuizModule"), hidden: 1 },
  { path: "coursebycat", name: 'CourseByCat', loadChildren: () => require("./components/coursebycat/coursebycat.module#CourseByCatModule"), hidden: 1 },
  { path: "coursebycatdetails", name: 'CourseByCatDetails', loadChildren: () => require("./components/coursebycat/details/coursebycatdetails.module#CourseByCatDetailsModule"), hidden: 1 },
];


export const routing = NativeScriptRouterModule.forRoot(appRoutes);

Error:

ERROR in Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 19:49 in the original .ts file), resolving symbol appRoutes in D:/Others/Documents/My_Work/NativeScript/app/routing.ts, resolving symbol routing in D:/Others/Documents/My_Work/NativeScript/app/routing.ts, resolving symbol routing in D:/Others/Documents/My_Work/NativeScript/app/routing.ts, resolving symbol AppModule in D:/Others/Documents/My_Work/NativeScript/app/app.module.ts, resolving symbol AppModule in D:/Others/Documents/My_Work/NativeScript/app/app.module.ts

ERROR in ./main.aot.ts
Module not found: Error: Can't resolve './app.module.ngfactory' in 'D:\Others\Documents\My_Work\NativeScript\app'
 @ ./main.aot.ts 4:29-62
Child extract-text-webpack-plugin D:\Others\Documents\My_Work\NativeScript\node_modules\extract-text-webpack-plugin\dist D:\Others\Documents\My_Work\NativeScript\node_modules\resolve-url-loader\index.js??ref--1-1!D:\Others\Documents\My_Work\NativeScript\node_modules\nativescript-css-loader\index.js??ref--1-2!D:\Others\Documents\My_Work\NativeScript\node_modules\nativescript-dev-webpack\platform-css-loader.js!D:\Others\Documents\My_Work\NativeScript\app\app.css:
       [1] ../node_modules/resolve-url-loader?{"silent":true,"absolute":false,"sourceMap":false,"fail":false,"keepQuery":false,"debug":false,"root":null,"includeRoot":false}!../node_modules/nativescript-css-loader?{"minimize":false}!../node_modules/nativescript-dev-webpack/platform-css-loader.js!./app.css 950 bytes {0} [built]
       [3] ../node_modules/nativescript-css-loader?{"minimize":false}!./assets/css/custom.css 3.62 kB {0} [built]

@iguissouma
Copy link

@jibon57 try to use string-based routes like loadChildren: './components/about/about.module#AboutModule'

Or I think you should extract the loadChildren in a function so the aot compilation can work:
export function loadAboutModuleChildren (){require("./components/about/about.module#AboutModule")}
.....
then in routes
{ name: "About", path: "about", loadChildren: loadAboutModuleChildren, hidden: 0, login: 1, logout: 1 },

@jibon57
Copy link

jibon57 commented Aug 8, 2017

@iguissouma Thanks but I am getting this error now:

 [110] .. lazy 160 bytes {2} [built]
 [160] ./main.aot.ts 363 bytes {0} [built]
 [164] ./package.json 84 bytes {2} [optional] [built]
 [205] ./vendor.ts 484 bytes {2} [built]
 [206] ./vendor-platform.android.ts 539 bytes {2} [built]
 [257] ./app.css 41 bytes {1} [built]
 [260] ../node_modules/nativescript-css-loader?{"minimize":false}!./assets/css/custom.css 3.62 kB [built]
    + 254 hidden modules

ERROR in Cannot read property 'name' of undefined

ERROR in ./main.aot.ts
Module not found: Error: Can't resolve './app.module.ngfactory' in 'D:\Others\Documents\My_Work\NativeScript\app'
 @ ./main.aot.ts 4:29-62
Child app\components\home\home.html:
       1 module
Child app\components\dashboard\dashboard.html:
       1 module
Child app\components\mycourses\mycourses.html:
       1 module
Child app\components\about\about.html:
       1 module
Child app\components\blog\popup\blog.popup.html:
       1 module
Child app\components\blog\blog.html:
       1 module
Child app\components\coursebycat\details\coursebycatdetails.html:
       1 module
Child app\components\coursebycat\coursebycat.html:
       1 module
Child app\components\coursedetails\coursedetails.html:
       1 module
Child app\components\forum\forum.html:
       1 module
Child app\components\forum\popup\forum.popup.html:
       1 module
Child app\components\logout\logout.html:
       1 module
Child app\components\login\login.html:
       1 module
Child app\components\product\product.html:
       1 module
Child app\components\product\popup\product.popup.html:
       1 module
Child app\components\coursemodules\dubbing\dubbing.html:
       1 module
Child app\components\video\video.html:
       1 module
Child app\components\shared\menu\menu.html:
       1 module
Child app\components\coursemodules\glossary\glossary.html:
       1 module
Child app\components\coursemodules\jibon\jibon.html:
       1 module
Child app\components\coursemodules\page\page.html:
       1 module
Child app\components\coursemodules\quiz\quiz.html:
       1 module
Child app\components\mycourses\mycourses.css:
       1 module
Child app\components\home\home.css:
       1 module
Child app\components\dashboard\dashboard.css:
       1 module
Child app\components\blog\blog.css:
       1 module
Child app\components\coursebycat\details\coursebycatdetails.css:
       1 module
Child app\components\coursebycat\coursebycat.css:
       1 module
Child app\components\coursedetails\coursedetails.css:
       1 module
Child app\components\forum\forum.css:
       1 module
Child app\components\forum\popup\forum.popup.css:
       1 module
Child app\components\logout\logout.css:
       1 module
Child app\components\login\login.css:
       1 module
Child app\components\product\product.css:
       1 module
Child app\components\coursemodules\dubbing\dubbing.css:
       1 module
Child app\components\coursemodules\jibon\jibon.css:
       1 module
Child app\components\coursemodules\glossary\glossary.css:
       1 module
Child app\components\product\popup\product.popup.css:
       1 module
Child app\components\coursemodules\page\page.css:
       1 module
Child app\components\coursemodules\quiz\quiz.css:
       1 module
Child extract-text-webpack-plugin D:\Others\Documents\My_Work\NativeScript\node_modules\extract-text-webpack-plugin\dist D:\Others\Documents\My_Work\NativeScript\node_modules\resolve-url-loader\index.js??ref--1-1!D:\Others\Documents\My_Work\NativeScript\node_modules\nativescript-css-loader\index.js??ref--1-2!D:\Others\Documents\My_Work\NativeScript\node_modules\nativescript-dev-webpack\platform-css-loader.js!D:\Others\Documents\My_Work\NativeScript\app\app.css:
       [1] ../node_modules/resolve-url-loader?{"silent":true,"absolute":false,"sourceMap":false,"fail":false,"keepQuery":false,"debug":false,"root":null,"includeRoot":false}!../node_modules/nativescript-css-loader?{"minimize":false}!../node_modules/nativescript-dev-webpack/platform-css-loader.js!./app.css 950 bytes {0} [built]
       [3] ../node_modules/nativescript-css-loader?{"minimize":false}!./assets/css/custom.css 3.62 kB {0} [built]
        + 2 hidden modules
Webpack Bundle Analyzer saved stats file to D:\Others\Documents\My_Work\NativeScript\report\stats.json
Webpack Bundle Analyzer saved report to D:\Others\Documents\My_Work\NativeScript\report\report.html
child process exited with code 2

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "ns-bundle" "--android" "--run-app"
npm ERR! node v6.9.2
npm ERR! npm  v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! @ ns-bundle: `ns-bundle`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the @ ns-bundle script 'ns-bundle'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ns-bundle
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     D:\Others\Documents\My_Work\NativeScript\npm-debug.log

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "start-android-bundle"
npm ERR! node v6.9.2
npm ERR! npm  v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! @ start-android-bundle: `npm run ns-bundle --android --run-app`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ start-android-bundle script 'npm run ns-bundle --android --run-app'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run ns-bundle --android --run-app
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     D:\Others\Documents\My_Work\NativeScript\npm-debug.log

@iguissouma
Copy link

Did you use the literal string or function? Your problem is not the same it's related to lazy loading and aot compilation, Try to open a new issue.
I Will do more tests and keep you updated.

@jibon57
Copy link

jibon57 commented Aug 9, 2017

@iguissouma Thanks for your help. I have opened a new issue here: #249 .. Please help me to resolve this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants