question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[AOT] @ngtools/webpack throws "Cannot find module './ngfactory/app/app.module.ngfactory'"

See original GitHub issue

OS?

Windows_NT 10.0.10586

Description.

I’m trying to integrate @ngtools/webpack into my custom webpack build and is getting Cannot find module './ngfactory/app/app.module.ngfactory' error. The source of the error is here. I’ve managed to suppress the error by disabling this check.

Repro steps.

Github repo: https://github.com/DzmitryShylovich/ngtools-error

npm i
npm start

The log given by the failure.

ERROR in ./app/main.aot.ts
Module build failed: Error: D:/Workspace/ngtools-error/app/main.aot.ts (3,34): Cannot find module './ngfactory/app/app.module.ngfactory'.)
    at _transpile (D:\Workspace\ngtools-error\node_modules\@ngtools\webpack\src\loader.js:101:19)
    at D:\Workspace\ngtools-error\node_modules\@ngtools\webpack\src\loader.js:125:26

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:16
  • Comments:19 (4 by maintainers)

github_iconTop GitHub Comments

25reactions
Meligycommented, Jan 16, 2017

Anyone still getting this?

8reactions
karthikeyanVKcommented, Mar 10, 2017

When you run the ng build in angular 2, latest angular-cli automatically runs with --aot parameter (ahead of time compilation), so it is trying to optimize your code. You are having a package that is not yet compatible for optimizing. So you need update to your packages. Most probably the packages that has forRoot() in your app.module.ts

I recommend to update all packages.

Easy way to update your package is to the use package below, which i got it from http://stackoverflow.com/questions/36597780/how-do-i-correctly-upgrade-angular-2-npm-to-the-latest-version

Install

npm install -g npm-check-updates

Usage

ncu for display

ncu -u for re-writing your package.json

and run npm install to update your packages

Read more comments on GitHub >

github_iconTop Results From Across the Web

1
I'm trying to integrate AOT in my project angular project. it throws the error when running the project. GET http://localhost:3000/aot/app/app.
Read more >
angular/angular - Gitter
module have declared 'Landlord module'. Redirect appears when i refresh in landlord/help (child component). In addition my Landlord module have ...
Read more >
Switching from angular2-template-loader to @ngtools ...
Module not found: Error: Can't resolve './main.ts.ngfactory' in '/path/to/application/directory'. Another strange problem that I don't ...
Read more >
how should I generate the app.module.ngfactory.ts file?
I'm trying to get my ng2 app set up for AOT. It seems that an app.module.ngfactory.ts file is needed for this instead of...
Read more >
module not found: error: can't resolve '@angular/localize/init'
I get an exception throw Module not found: Error: Cant resolve ... Here is how you can do it: @Component ( { selector:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found