Skip to content
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

AOT Error --- Can't find app.module #2577

Closed
deebloo opened this issue Oct 7, 2016 · 25 comments
Closed

AOT Error --- Can't find app.module #2577

deebloo opened this issue Oct 7, 2016 · 25 comments
Assignees
Labels
P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful

Comments

@deebloo
Copy link
Contributor

deebloo commented Oct 7, 2016

OS?

OSX - El Capitan

Versions.

angular-cli: 1.0.0-beta.17
node: 6.7.0

Repro steps.

-- Create a clean app with ng new hello
-- open src/app/index.ts
-- change line 2 from

export * from './app.module';

to

export { AppModule } from './app.module';

-- run ng build --prod --aot

The log given by the failure.

ENOENT: no such file or directory, stat '/Users/dannyblue/Documents/projects/ls-dashboard/src/app/app.module'
Error: ENOENT: no such file or directory, stat '/Users/dannyblue/Documents/projects/ls-dashboard/src/app/app.module'
at Error (native)
at Object.fs.statSync (fs.js:987:18)
at _symbolImportLookup (/Users/dannyblue/Documents/projects/ls-dashboard/node_modules/@ngtools/webpack/src/entry_resolver.js:103:28)
at Object.resolveEntryModuleFromMain (/Users/dannyblue/Documents/projects/ls-dashboard/node_modules/@ngtools/webpack/src/entry_resolver.js:148:18)
at AotPlugin._setupOptions (/Users/dannyblue/Documents/projects/ls-dashboard/node_modules/@ngtools/webpack/src/plugin.js:105:77)
at new AotPlugin (/Users/dannyblue/Documents/projects/ls-dashboard/node_modules/@ngtools/webpack/src/plugin.js:34:14)
at Object.exports.getWebpackAotConfigPartial (/Users/dannyblue/Documents/projects/ls-dashboard/node_modules/angular-cli/models/webpack-build-typescript.js:57:13)
at new NgCliWebpackConfig (/Users/dannyblue/Documents/projects/ls-dashboard/node_modules/angular-cli/models/webpack-config.js:18:42)
at Class.run (/Users/dannyblue/Documents/projects/ls-dashboard/node_modules/angular-cli/tasks/build-webpack.js:17:22)
at Class.run (/Users/dannyblue/Documents/projects/ls-dashboard/node_modules/angular-cli/commands/build.js:50:26)
at Class. (/Users/dannyblue/Documents/projects/ls-dashboard/node_modules/angular-cli/lib/models/command.js:152:17)
at tryCatch (/Users/dannyblue/Documents/projects/ls-dashboard/node_modules/rsvp/dist/lib/rsvp/-internal.js:215:12)
at invokeCallback (/Users/dannyblue/Documents/projects/ls-dashboard/node_modules/rsvp/dist/lib/rsvp/-internal.js:230:13)
at publish (/Users/dannyblue/Documents/projects/ls-dashboard/node_modules/rsvp/dist/lib/rsvp/-internal.js:198:7)
at flush (/Users/dannyblue/Documents/projects/ls-dashboard/node_modules/rsvp/dist/lib/rsvp/asap.js:85:5)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)

Mention any other details that might be useful.

AOT was working fine for me in beta.16
If I change it back to a wild card the app will compile but I have two libs being served from node_modules and while the app will compile I get runtime errors such as:

Return type of public method from exported class has or is using name 'Observable' from external module "/Users/dannyblue/Documents/projects/ls-dashboard/node_modules/rxjs/Observable" but cannot be named.

Which also did not happen with beta.15. I will also point out that importing app module directly will also throw the same error at compile time.

import { AppModule } from './app/app.module';

I am curious if this has something to do with now doing the AOT compilation with a virtual file system.

@filipesilva filipesilva added P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful command: build and removed P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful labels Oct 7, 2016
@DzmitryShylovich
Copy link

microsoft/TypeScript#9944

@deebloo
Copy link
Contributor Author

deebloo commented Oct 9, 2016

@filipesilva update. I also cannot go back to beta.16. If I install beta.16 specifically I now get. I am assuming this has to do with one of the internal packages updated for 17?

webpack_1.NgcWebpackPlugin is not a constructor
TypeError: webpack_1.NgcWebpackPlugin is not a constructor
    at Object.exports.getWebpackAotConfigPartial (/Users/dannyblue/Documents/projects/ls-dashboard/node_modules/angular-cli/models/webpack-build-typescript.js:50:13)
    at new NgCliWebpackConfig (/Users/dannyblue/Documents/projects/ls-dashboard/node_modules/angular-cli/models/webpack-config.js:18:42)
    at Class.run (/Users/dannyblue/Documents/projects/ls-dashboard/node_modules/angular-cli/tasks/build-webpack.js:17:22)
    at Class.run (/Users/dannyblue/Documents/projects/ls-dashboard/node_modules/angular-cli/commands/build.js:50:26)
    at Class.<anonymous> (/Users/dannyblue/Documents/projects/ls-dashboard/node_modules/angular-cli/lib/models/command.js:152:17)
    at tryCatch (/Users/dannyblue/Documents/projects/ls-dashboard/node_modules/rsvp/dist/lib/rsvp/-internal.js:215:12)
    at invokeCallback (/Users/dannyblue/Documents/projects/ls-dashboard/node_modules/rsvp/dist/lib/rsvp/-internal.js:230:13)
    at publish (/Users/dannyblue/Documents/projects/ls-dashboard/node_modules/rsvp/dist/lib/rsvp/-internal.js:198:7)
    at flush (/Users/dannyblue/Documents/projects/ls-dashboard/node_modules/rsvp/dist/lib/rsvp/asap.js:85:5)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

I am also willing to help test and debug. I looked through the code a bit and found where the error noted in the issue happening but couldn't make any progress from there. The path is correct but node just doesn't seem to think it exists.

@filipesilva
Copy link
Contributor

@deebloo nuke your local node_modules. Semver must have accepted the newer versions.

@deebloo
Copy link
Contributor Author

deebloo commented Oct 9, 2016

@filipesilva already tried nuking and clearing the cache. something must be getting stuck somewhere hmmm. Will try on a different machine.

@filipesilva
Copy link
Contributor

filipesilva commented Oct 9, 2016

@deebloo local and global? I noticed that the @ngtools/webpack (the aot plugin) is just pointing at latest, so there might be a version problem in beta.16 now.

@deebloo
Copy link
Contributor Author

deebloo commented Oct 9, 2016

@filipesilva yup local and global. what version of @ngtools/webpack should be used by beta.16? (so i could add it to my local for now)

@jaykhimani
Copy link

Same happens with ng build as well.

@filipesilva
Copy link
Contributor

@deebloo should be @ngtools/webpack@1.0.0 I believe.

@Gamblt
Copy link

Gamblt commented Oct 11, 2016

@ngtools/webpack@1.0.0 didn't help :(
Error still appears...

@OnlyByGrace
Copy link

OnlyByGrace commented Oct 12, 2016

@Gamblt Installing the right version locally wasn't enough; cli keeps it's own version at node_modules/angular-cli/node_modules Deleting that version after installing @ngtools/weback@1.0.0 worked for me.

@Gamblt
Copy link

Gamblt commented Oct 14, 2016

@OnlyByGrace That's it! Works! Thanks a lot!!!

@filipesilva
Copy link
Contributor

Another way to repro from #2734 (comment)


If i use index.ts (barel file) it works, if i import main module directly:

import { MainModule } from './main/main.module';
it doesnt.

HOW TO SIMULATE:

  1. create new app with ng new
  2. change
import { AppModule } from './app'; 

to

import { AppModule } from './app/app.module'; 

in main.ts

@brendanalexdr
Copy link

modifying the reference to index.ts didn't do the trick for me. I am still getting (same as deebloo):

$ ng build -prod -aot
webpack_1.NgcWebpackPlugin is not a constructor
TypeError: webpack_1.NgcWebpackPlugin is not a constructor
at Object.exports.getWebpackAotConfigPartial (C:\my-project\node_modules\angular-cli\models\webpack-build-typescript.js:50:13)
at new NgCliWebpackConfig (C:\my-project\node_modules\angular-cli\models\webpack-config.js:18:42)
at Class.exports.default.Task.extend.run (C:\my-project\node_modules\angular-cli\tasks\build-webpack.js:17:22)
at Class.Command.extend.run (C:\my-project\node_modules\angular-cli\commands\build.js:50:26)
at Class. (C:\my-project\node_modules\angular-cli\lib\models\command.js:152:17)
at tryCatch (C:\my-project\node_modules\rsvp\dist\lib\rsvp-internal.js:215:12)
at invokeCallback (C:\my-project\node_modules\rsvp\dist\lib\rsvp-internal.js:230:13)
at C:\my-project\node_modules\rsvp\dist\lib\rsvp\then.js:29:16
at flush (C:\my-project\node_modules\rsvp\dist\lib\rsvp\asap.js:85:5)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)

@elvirdolic
Copy link

We have the same issue. No matter how we import the main module

@a5hik
Copy link

a5hik commented Oct 27, 2016

Facing the same problem..!

@elvirdolic
Copy link

I have solved this issue by using the same app.module import logic as it is with a new ng cli project

@jaykhimani
Copy link

@elvirdolic what do yo mean by using the same app.module import logic as it is with a new cli project? Would like to give it a try.

@elvirdolic
Copy link

index.ts

export * from './app.component';
export * from './app.module';

main.ts

import './polyfills.ts';

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { environment } from './environments/environment';
import { AppModule } from './app/';

if (environment.production) {
enableProdMode();
}

platformBrowserDynamic().bootstrapModule(AppModule);

this worked. Before I imported the AppModule from /app/app.module and this
is not working at the moment

2016-11-03 14:55 GMT+01:00 Jay Khimani notifications@github.com:

@elvirdolic https://github.com/elvirdolic what do yo mean by using the
same app.module import logic as it is with a new cli project? Would like
to give it a try.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#2577 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AQ8j8uELCFrbhj3z_0caMfEcHb2OmIREks5q6eflgaJpZM4KRf0X
.

@jaykhimani
Copy link

jaykhimani commented Nov 3, 2016

@elvirdolic ah nice. that worked. Thanks.

And now when I am reading the whole thread again, wondering how could I miss comment from @filipesilva which mentioned exact same thing.

@elvirdolic
Copy link

I have read the comment and did the same but what I did was following: import { AppModule } from './app/index' and this is also not working

strange!

@mrgoos
Copy link

mrgoos commented Dec 4, 2016

Hi,
is it working for everyone? I have issues the same as described here.
This is from main.ts:
import { AppModule } from './app/app.module';
This is from index.ts:
export * from './app.component'; export * from './app.module';
And --aot is not working. Tried ng serve --aot and ng serve --prod --aot

Running "version": "1.0.0-beta.19-3"
Thanks.

@mrgoos
Copy link

mrgoos commented Dec 4, 2016

It seems that it DOES work when I change this line in main.ts:
import { AppModule } from './app';
Is that a good thing to do?

I have other issues but it must be related to be AOT ready, I'm handling it but at least it's not shouting for errors right on the start.

@hansl
Copy link
Contributor

hansl commented Feb 3, 2017

Closing this as deprecated. This should be working now.

@hansl hansl closed this as completed Feb 3, 2017
@GoceBogdanovski
Copy link

main.ts > import { AppModule } from './app/app.module.js';

app.module.ts > import { AppComponent } from './app.component.js';

just add .js

@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 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful
Projects
None yet
Development

No branches or pull requests