Skip to content

Error in Could not resolve app module with @ngtools/webpack 1.3.1 #6462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 2 tasks
GiuseppePiscopo opened this issue May 25, 2017 · 10 comments
Closed
1 of 2 tasks
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent severity5: regression type: bug/fix workaround2: non-obvious

Comments

@GiuseppePiscopo
Copy link

GiuseppePiscopo commented May 25, 2017

Bug Report or Feature Request (mark with an x)

Versions.

  • Output from: ng --version. ng is not installed in this project. @ngtools/webpack is.
  • output from: node --version: v6.2.2
  • npm --version: 3.9.5
  • OS: Windows 10 version 1703, as well as Mac OS Sierra
  • angular 4.1.3,
  • @ngtools/webpack 1.3.1,
  • webpack 2.5.1,
  • typescript 2.3.2.

Repro steps.

There's a mini sample project showing the issue.

  1. Clone repository https://github.com/BrainCrumbz/ngtools-webpack-demo and change dir
  2. npm i
  3. npm run build-prod

The log given by the failure.

[...redacted...]
 [378] ./~/tslib/tslib.es6.js 8.02 kB {1} [built]
       [] -> factory:652ms building:2489ms = 3141ms
 [379] ./~/zone.js/dist/zone.min.js 29.8 kB {1} [built]
       [] -> factory:2333ms building:2441ms dependencies:616ms = 5390ms
    + 369 hidden modules

ERROR in Could not resolve "src/app/module" from "src/app/module".
Child src\shared\view\not-found.component.html:
       [0] ./src/shared/view/not-found.component.html 376 bytes {0} [built]
            factory:132ms building:31ms = 163ms
Child src\private\view\component.html:
       [0] ./src/private/view/component.html 291 bytes {0} [built]
            factory:116ms building:38ms = 154ms
[...redacted...]

Desired functionality.

Build should complete successfully.

Mention any other details that might be useful.

The app has a lazily loaded module (dubbed private). You can build it in development as well (npm run build-dev), serve it from another shell (npm run serve) and browse to localhost:3000. The readme in repository root shows all npm commands.

The AOT build is not using full angular-cli, just @ngtools/webpack.

I tried fiddling with angularCompilerOptions.genDir value in AOT tsconfig, with no luck. That just changed the error message, for example it changed the path as Could not resolve "./src/app/module" from "./src/app/module"., but no real clue about it.

@hansl
Copy link
Contributor

hansl commented May 25, 2017

This has been (supposedly) fixed in 1.3.3. Could you please try again with that version?

@GiuseppePiscopo
Copy link
Author

D'oh! Didn't know there was a newer version, just checked some days ago (from VSCode intellisense).

Will report ASAP. Thanks for quick reply.

@GiuseppePiscopo
Copy link
Author

GiuseppePiscopo commented May 25, 2017

Just tried uninstalling previous version and installing 1.3.3. No luck, same console output apparently:

[...]
 [167] ./src/vendor-aot.ts 401 bytes {1} [built]
        factory:14722ms building:187ms = 14909ms
 [378] ./~/tslib/tslib.es6.js 8.02 kB {1} [built]
       [] -> factory:1278ms building:3519ms = 4797ms
 [379] ./~/zone.js/dist/zone.min.js 29.8 kB {1} [built]
       [] -> factory:3742ms building:2917ms dependencies:1009ms = 7668ms
    + 369 hidden modules

ERROR in Could not resolve "src/app/module" from "src/app/module".
Child src\shared\view\not-found.component.html:
       [0] ./src/shared/view/not-found.component.html 376 bytes {0} [built]
            factory:174ms building:31ms = 205ms
Child src\private\view\component.html:
       [0] ./src/private/view/component.html 291 bytes {0} [built]
            factory:158ms building:65ms = 223ms
[...]

BTW repo is updated too now

@mradcliffe
Copy link

I'm having a similar issue with @angular/cli 1.0.5 not resolving modules such as "app/module", but will resolve relative path modules. Downgrading to @angular/cli 1.0.4 and still using ngtools/webpack 1.3.1 resolves the issue.

@hansl
Copy link
Contributor

hansl commented May 25, 2017

@mradcliffe that error has been fixed by 1.0.6. This is a different error.

@GiuseppePiscopo we're going to investigate.

@hansl hansl added package4: @angular-sdk/webpack P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent severity5: regression type: bug/fix workaround2: non-obvious labels May 25, 2017
@hansl
Copy link
Contributor

hansl commented May 26, 2017

@GiuseppePiscopo Oh I just saw what's going on in your code.

In order to do what you're trying to do, you have to add a baseUrl in your tsconfig. Without a baseUrl, TypeScript will try to resolve those non-relative paths with node module, but obviously it's not in node_modules.

Adding a "baseUrl": "" in your tsconfig fixes it. :)

@hansl hansl closed this as completed May 26, 2017
@GiuseppePiscopo
Copy link
Author

Oh my... well, first of all big thanks, don't know how much time would I have spent (more) looking for something like that. At some point I remember having that option set, but then removing it. Is that shown somewhere in big prints? I'd be happy to submit a doc PR if needed.

Now, I guess I'll have to search through past issues for this runtime error on lazy loaded module, it must have been fixed/covered as well:

vendor-bundle.js:8 ERROR Error: Uncaught (in promise): Error: Cannot find module '../private/module.ngfactory'.
Error: Cannot find module '../private/module.ngfactory'.
at e (main-bundle.js:1)
at t.loadFactory (vendor-bundle.js:162)
at t.load (vendor-bundle.js:162)
at t.loadModuleFactory (vendor-bundle.js:415)
at t.load (vendor-bundle.js:415)
at e.project (vendor-bundle.js:415)
at e._tryNext (vendor-bundle.js:436)
at e._next (vendor-bundle.js:436)
at e.next (vendor-bundle.js:1)
at e._subscribe (vendor-bundle.js:436)
at e (main-bundle.js:1)
[...redacted...]

@GiuseppePiscopo
Copy link
Author

GiuseppePiscopo commented May 26, 2017

Uhm, the recent issue talking about this, #4637, was closed due to version moving further, but not really addressing it ... would you consider re-opening this, or maybe I should create a new dedicated issue?

GiuseppePiscopo added a commit to BrainCrumbz/ngtools-webpack-demo that referenced this issue May 26, 2017
@GiuseppePiscopo
Copy link
Author

Without uglifyjs plugin, stacktrace is:

core.es5.js:1084 ERROR Error: Uncaught (in promise): Error: Cannot find module '../private/module.ngfactory'.
Error: Cannot find module '../private/module.ngfactory'.
at webpackEmptyContext (main-bundle.js:7)
at SystemJsNgModuleLoader.loadFactory (core.es5.js:5915)
at SystemJsNgModuleLoader.load (core.es5.js:5887)
at RouterConfigLoader.loadModuleFactory (router.es5.js:3334)
at RouterConfigLoader.load (router.es5.js:3318)
at MergeMapSubscriber.project (router.es5.js:1565)
at MergeMapSubscriber._tryNext (mergeMap.js:120)
at MergeMapSubscriber._next (mergeMap.js:110)
at MergeMapSubscriber.Subscriber.next (Subscriber.js:89)
at ScalarObservable._subscribe (ScalarObservable.js:49)
at webpackEmptyContext (main-bundle.js:7)
at SystemJsNgModuleLoader.loadFactory (core.es5.js:5915)
at SystemJsNgModuleLoader.load (core.es5.js:5887)
at RouterConfigLoader.loadModuleFactory (router.es5.js:3334)
at RouterConfigLoader.load (router.es5.js:3318)
at MergeMapSubscriber.project (router.es5.js:1565)
at MergeMapSubscriber._tryNext (mergeMap.js:120)
at MergeMapSubscriber._next (mergeMap.js:110)
at MergeMapSubscriber.Subscriber.next (Subscriber.js:89)
at ScalarObservable._subscribe (ScalarObservable.js:49)
at c (zone.min.js:1)
at c (zone.min.js:1)
at zone.min.js:1
at e.invokeTask (zone.min.js:1)
at Object.onInvokeTask (core.es5.js:4140)
at e.invokeTask (zone.min.js:1)
at r.runTask (zone.min.js:1)
at o (zone.min.js:1)
at HTMLAnchorElement.invoke (zone.min.js:1)
defaultErrorLogger @ core.es5.js:1084
ErrorHandler.handleError @ core.es5.js:1144
next @ core.es5.js:4778
schedulerFn @ core.es5.js:3851
SafeSubscriber.__tryOrUnsub @ Subscriber.js:223
SafeSubscriber.next @ Subscriber.js:172
Subscriber._next @ Subscriber.js:125
Subscriber.next @ Subscriber.js:89
Subject.next @ Subject.js:55
EventEmitter.emit @ core.es5.js:3837
NgZone.triggerError @ core.es5.js:4209
onHandleError @ core.es5.js:4170
e.handleError @ zone.min.js:1
r.runGuarded @ zone.min.js:1
e @ zone.min.js:1
n.microtaskDrainDone @ zone.min.js:1
o @ zone.min.js:1
invoke @ zone.min.js:1

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent severity5: regression type: bug/fix workaround2: non-obvious
Projects
None yet
Development

No branches or pull requests

4 participants