ng-tools/webpack unable to resolve app.module.ts.ngfactory
See original GitHub issueOS?
Mac OSX (El Capitan)
Versions.
ng-tools/webpack: 1.2.4 node: v5.11.0 angular-cli: 2.4.4 webpack: 2.2.0
Repro steps.
Using a custom made webpack config file. Trying to use ng-tools/webpack plugin to generate a build using AOT.
The log given by the failure.
stream.js:74
throw er; // Unhandled stream error in pipe.
^
Error: ./src/client/app.ts
Module not found: Error: Can't resolve './aot/src/client/app.module.ts.ngfactory' in '/Volumes/User/oliver/htdocs/tu-prestamo-2/src/client'
resolve './aot/src/client/app.module.ts.ngfactory' in '/Volumes/User/oliver/htdocs/tu-prestamo-2/src/client'
using description file: /Volumes/User/oliver/htdocs/tu-prestamo-2/package.json (relative path: ./src/client)
Field 'browser' doesn't contain a valid alias configuration
after using description file: /Volumes/User/oliver/htdocs/tu-prestamo-2/package.json (relative path: ./src/client)
using description file: /Volumes/User/oliver/htdocs/tu-prestamo-2/package.json (relative path: ./src/client/aot/src/client/app.module.ts.ngfactory
)
as directory
/Volumes/User/oliver/htdocs/tu-prestamo-2/src/client/aot/src/client/app.module.ts.ngfactory doesn't exist
no extension
Field 'browser' doesn't contain a valid alias configuration
/Volumes/User/oliver/htdocs/tu-prestamo-2/src/client/aot/src/client/app.module.ts.ngfactory doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
/Volumes/User/oliver/htdocs/tu-prestamo-2/src/client/aot/src/client/app.module.ts.ngfactory.js doesn't exist
.ts
Field 'browser' doesn't contain a valid alias configuration
/Volumes/User/oliver/htdocs/tu-prestamo-2/src/client/aot/src/client/app.module.ts.ngfactory.ts doesn't exist
.scss
Field 'browser' doesn't contain a valid alias configuration
/Volumes/User/oliver/htdocs/tu-prestamo-2/src/client/aot/src/client/app.module.ts.ngfactory.scss doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
/Volumes/User/oliver/htdocs/tu-prestamo-2/src/client/aot/src/client/app.module.ts.ngfactory.json doesn't exist
[/Volumes/User/oliver/htdocs/tu-prestamo-2/src/client/aot/src/client/app.module.ts.ngfactory]
[/Volumes/User/oliver/htdocs/tu-prestamo-2/src/client/aot/src/client/app.module.ts.ngfactory]
[/Volumes/User/oliver/htdocs/tu-prestamo-2/src/client/aot/src/client/app.module.ts.ngfactory.js]
[/Volumes/User/oliver/htdocs/tu-prestamo-2/src/client/aot/src/client/app.module.ts.ngfactory.ts]
[/Volumes/User/oliver/htdocs/tu-prestamo-2/src/client/aot/src/client/app.module.ts.ngfactory.scss]
[/Volumes/User/oliver/htdocs/tu-prestamo-2/src/client/aot/src/client/app.module.ts.ngfactory.json]
@ ./src/client/app.ts 3:0-78
Mention any other details that might be useful.
app.module.ts:
import './polyfills.ts';
import { AppModule } from './app.module';
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
declare var ENVIRONMENT: string; // Webpack DefinePlugin.
if (ENVIRONMENT === "production") {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule);
tsconfig.aot.json:
{
"compilerOptions": {
"target": "es6",
"module": "es6",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"sourceMap": true,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
},
"angularCompilerOptions": {
"skipMetadataEmit" : true,
"genDir": "./src/client/aot",
"debug": true
}
}
webpack.config:
...
plugins: [
new AotPlugin({
tsConfigPath: './tsconfig.aot.json',
entryModule: __dirname + '/src/client/app.module.ts#AppModule',
}),
...
Would like to provide more useful information. But the trace stack is not very helpful.
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (3 by maintainers)
Top Results From Across the Web
0 - Stack Overflow
ngcli 6.1.3 ERROR in ./src/main.ts - Can't resolve './app/app.module.ngfactory' · Ask Question.
Read more >Google Groups
ClientApp/boot.browser.ts Module not found: Error: Can't resolve './app/app.browser.module.ngfactory'. 189 views. Skip to first unread message.
Read more >Angular - Code with Mosh Forum
ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js): Error: Emit attempted before Angular Webpack plugin ...
Read more >ngtools/webpack: missing app.module.ngfactory-node.js
The thing about @ngtools/webpack is that it creates those .ngfactory files in memory. Therefore there is no need to have any main.aot.ts ....
Read more >How to configure Webpack 4 with Angular 7: a complete guide
ts that only imports the application's third-party modules. polyfills.ts we need polyfills to run an Angular application in most browsers as ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@olivercs, I had similar error that was caused by .ts file extension that I’ve mentioned in entryModule configuration (it doesn’t matter whether entryModule is configured in webpack.config.js or in tsconfig.json).
So after I’ve removed .ts extension from my tsconfig.json entryModule configuration the error was gone.
Before:
After:
I hope this info would be helpful to you.
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.