angular-cli: ERROR in Could not resolve "./src/app/app.module" from "./src/app/app.module".
OS?
Xubuntu
Versions.
Node: 6.0.0 Angular: 4.0.0-beta.8 ‘@ngtools/webpack’ plugin: 1.2.10
Repro steps.
new AotPlugin({
tsConfigPath: './tsconfig.json',
entryModule: './src/app/app.module#AppModule'
})
main.ts
import './vendors.ts';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { environment } from './environments/environment';
import { AppModule } from './app/app.module';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule);
app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { CommonModule } from '@angular/common';
import { GeneratorAppModule } from './generator-app/generator-app.module'
import { AppComponent } from './app.component';
@NgModule({
imports: [
BrowserModule,
CommonModule,
GeneratorAppModule
],
declarations: [
AppComponent
],
bootstrap:[
AppComponent
]
})
export class AppModule { }
The log given by the failure.
ERROR in Could not resolve "./src/app/app.module" from "./src/app/app.module".
This error occurs only wiht AOT compilation.
I using Webpack @ngtools/webpack
plugin. Code compiled fine, it runnable, but i got this error.
Full stack trace:
Hash: 50a4ef2cbf71037e65e7
Version: webpack 2.2.1
Time: 65029ms
Asset Size Chunks Chunk Names
main.js 740 kB 0 [emitted] [big] main
vendor.js 112 kB 1 [emitted] vendor
main.js.map 2.37 MB 0 [emitted] main
vendor.js.map 377 kB 1 [emitted] vendor
index.html 934 bytes [emitted]
[0] ./~/@angular/core/index.js 2.61 kB {0} [built]
[22] ./~/tslib/tslib.es6.js 5.03 kB {1} [built]
[55] ./~/core-js/modules/_core.js 117 bytes {1} [built]
[193] ./~/@angular/platform-browser/index.js 716 bytes {0} [built]
[266] ./src/vendors.ts 153 bytes {1} [built]
[302] ./~/@angular/forms/src/form_builder.js 4.82 kB {0} [built]
[329] ./src/environments/environment.ts 102 bytes {0} [built]
[382] ./src/main.ts 496 bytes {0} [built]
[467] ./$$_gendir/src/app/app.module.ngfactory.ts 41.8 kB {0} [built]
[483] ./~/core-js/es6/index.js 5.88 kB {1} [built]
[484] ./~/core-js/es7/reflect.js 510 bytes {1} [built]
[504] ./~/core-js/modules/es6.array.join.js 451 bytes {1} [built]
[681] ./~/zone.js/dist/zone.js 85.1 kB {1} [built]
[690] multi ./src/main.ts 28 bytes {0} [built]
[691] multi ./src/vendors.ts 28 bytes {1} [built]
+ 677 hidden modules
ERROR in Could not resolve "./src/app/app.module" from "./src/app/app.module".
npm ERR! Linux 3.13.0-107-generic
npm ERR! argv "/home/xxx/.nvm/versions/node/v6.0.0/bin/node" "/home/xxx/.nvm/versions/node/v6.0.0/bin/npm" "run" "build"
npm ERR! node v6.0.0
npm ERR! npm v3.8.6
npm ERR! code ELIFECYCLE
npm ERR! generator@1.0.0 build: `NODE_ENV=production $(npm bin)/webpack && find ./dist -name \*.js -exec cp {} ./public \;`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the generator@1.0.0 build script 'NODE_ENV=production $(npm bin)/webpack && find ./dist -name \*.js -exec cp {} ./public \;'.
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 generator package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! NODE_ENV=production $(npm bin)/webpack && find ./dist -name \*.js -exec cp {} ./public \;
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs generator
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls generator
npm ERR! There is likely additional logging output above.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 21
- Comments: 21
I have literally suffered from this weird error yesterday. The error message is not clear at all, and doesn’t show any error stack. The fix is very simple, just use the absolute path for your
entryModule
. You can use the pathhelper
to make your build more portable. See the code below:Also as a side note (unrelated to this error), I think have to use for AoT build
instead of
Issue found and solved.
I’ve tried all the above but I’m still getting an error when I build with AoT. Below is my error along with the relevant code. Can someone please help me figure out what I’m missing? It works when I build for development. It only errors out when I build with AoT. I’m using
@ngtools/webpack
.Error
Webpack Prod Config
tsconfig.json
main.ts
package.json
Hiwhen i am using
helpers = require(‘./helpers’);
How to resolve this?
No, i’m still using
platformBrowserDynamic
Could not resolve module ../column-a-table/atable.module relative to /src/app/app.module.ts
using ng build or even ng serve. if I use ng serve then i still get the error then i save again it runs but I cannot get ng build to work.ng new myapp Error: Path “/app/app.module.ts” does not exist. Path “/app/app.module.ts” does not exist.
I am getting this result can anyone help me.
@leBoer nice catch… I have just noticed that now. I started my project from this seed. I thought it is part of node (I’m new to node). It looks like a custom made util that uses
path
node module. This is how implemented$project_root/config/helpers.js
then in webpack.config I use require to import it
helpers = require('./helpers');
@sanex3339 Did you had to use platformBrowser instead of platformBrowserDynamic?