I have some problems to compile with aot, I am using an angular-universal repo link
the compilation of aot with npm run build: aot works perfectly with the initial repo, I have another own repository, in which I try to adapt this, when I add the server part and compile there is no problem, but when I add the part from the ./app client that contains the angular files, I get the following error.
Error in Cannot read property 'text' of undefined
Error in G: .......: Cannot find module './ngfactory/app/server-app.module.ngfactory'.
Error in ./src/..../main.server.aot.ts
Module not found:Error:Can't resolve './ngfactory/app/server-app.module.ngfactory' in ....
I understand that the ngfactory modules are generated before the execution of the aot theme, so I am surprised that these errors appear, because when I execute it without the part of my application ./app (only the one that has defect the repository), I do not skip any problem.
I guess it has to do with the topic of can not read property 'text', looking for lei that was for the subject of typescript, and they recommended me to download it, however I tried to do that, but it broke several packages.
This is my package.json
{
"name": "ng-universal-demo",
"version": "1.0.0",
"main": "index.js",
"repository": {},
"scripts": {
"start": "npm run build && npm run server",
"build": "webpack",
"build:server": "webpack --env.aot --env.server",
"build:aot": "webpack --env.aot --env.client & webpack --env.aot --env.server",
"build:prod": "webpack --env.aot --env.client -p & webpack --env.aot --env.server",
"prebuild": "npm run clean",
"prebuild:aot": "npm run clean",
"prebuild:prod": "npm run clean",
"clean": "rimraf dist",
"server": "nodemon dist/server.js",
"watch": "webpack --watch"
},
"engines": {
"node": ">=6.0.0"
},
"license": "MIT",
"dependencies": {
"@angular/animations": "^4.0.0",
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/forms": "^4.0.0",
"@angular/http": "^4.0.0",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/platform-server": "^4.0.0",
"@angular/router": "^4.0.0",
"@ngrx/core": "^1.2.0",
"@ngrx/effects": "^2.0.2",
"@ngrx/store": "^2.2.1",
"@ngrx/store-devtools": "^3.2.4",
"@nguniversal/express-engine": "^1.0.0-beta.1",
"angular2-jwt": "^0.2.2",
"bcrypt": "^1.0.2",
"body-parser": "^1.17.1",
"cookie-session": "^2.0.0-beta.1",
"express": "^4.15.2",
"express-session": "^1.15.2",
"jsonwebtoken": "^7.3.0",
"jwt": "^0.2.0",
"method-override": "^2.3.8",
"mongoose": "^4.9.3",
"ngrx-store-logger": "^0.1.7",
"passport": "^0.3.2",
"passport-local": "^1.0.0",
"redux": "^3.6.0",
"redux-devtools-extension": "^2.13.0",
"redux-session": "^1.0.3",
"rxjs": "^5.2.0",
"webpack-node-externals": "^1.5.4",
"xhr2": "^0.1.4",
"zone.js": "^0.8.5"
},
"devDependencies": {
"@angular/compiler-cli": "^4.0.0",
"@ngtools/webpack": "^1.2.14",
"@types/express": "^4.0.35",
"@types/node": "^7.0.8",
"html-webpack-plugin": "^2.28.0",
"nodemon": "^1.11.0",
"raw-loader": "^0.5.1",
"rimraf": "^2.6.1",
"script-ext-html-webpack-plugin": "^1.7.1",
"typescript": "^2.2.1",
"webpack": "^2.2.1",
"webpack-merge": "^4.0.0"
}
}
This is the structure of my documents in the ./app directory
./actions
./admin-panel
./components-shared
./effects
./models
./reducers
./services
app.component.html
app.component.ts
app.module.ts
browser-app.module.ts
server-app.module.ts
My app.module.ts
import { NgModule,CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { APP_BASE_HREF, CommonModule } from '@angular/common';
import { HttpModule } from '@angular/http';
import { RouterModule } from '@angular/router';
import { TransferHttpModule } from '../modules/transfer-http/transfer-http.module';
import { FormsModule } from '@angular/forms';
import {Store, StoreModule} from '@ngrx/store';
import {EffectsModule} from '@ngrx/effects';
//Components
import { AppComponent } from './app.component';
import { LazyView } from './+lazy/lazy.component';
//Services
import {
WikiService,
AuthService,
MenuService,
BlogService,
ForumService,
CategoryService,
UserService
} from './services';
//reducers
import reducer from './reducers';
//Modules local
import { AppWikiModule,WikiModule} from './app-wiki';
import { AdminPanelModule } from './admin-panel';
import { NavWikiModule,CrudModule } from './components-shared';
//Effects
import {
MenuWikiEffects,
MenuWikisEffects,
AuthEffects,
MenuAdminEffects
} from './effects/menu';
import {
CrudUserEffects,
CrudWikiEffects,
CrudBlogEffects,
CrudCategoryEffects,
CrudForumEffects
} from './effects/crud';
//Actions
import {
MenuWikiActions,
MenuWikisActions,
AuthActions,
MenuAdminActions,
} from './actions/menu';
import {
CrudUserActions,
CrudWikiActions,
CrudForumActions,
CrudBlogActions,
CrudCategoryActions
} from './actions/crud';
import { AuthGuard } from './guards/auth.guard';
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
@NgModule({
imports: [
CommonModule,
HttpModule,
TransferHttpModule,
BrowserModule,
RouterModule.forRoot([
{ path: 'lazy', component:LazyView},
]),
StoreModule.provideStore(reducer),
EffectsModule.run(MenuWikiEffects),
EffectsModule.run(MenuWikisEffects),
EffectsModule.run(AuthEffects),
EffectsModule.run(MenuAdminEffects),
EffectsModule.run(CrudUserEffects),
EffectsModule.run(CrudWikiEffects),
EffectsModule.run(CrudBlogEffects),
EffectsModule.run(CrudForumEffects),
EffectsModule.run(CrudCategoryEffects),
StoreDevtoolsModule.instrumentOnlyWithExtension({
maxAge: 5
}),
FormsModule,
AppWikiModule,
WikiModule,
AdminPanelModule,
CrudModule,
],
providers:[
MenuService,
UserService,
WikiService,
AuthService,
AuthGuard,
MenuWikiActions,
MenuWikisActions,
AuthActions,
MenuAdminActions,
CrudUserActions,
CrudWikiActions,
CrudCategoryActions,
CrudBlogActions,
CrudForumActions
],
declarations: [ AppComponent,LazyView],
exports: [ AppComponent ],
schemas:[CUSTOM_ELEMENTS_SCHEMA]
})
export class AppModule {}
The rest, brower-app.module, etc. I do not put it because it is exactly like in the repository that I put at the beginning, besides the failure only occurs when I try to compile with aot, because when I compile with jit, there is no failure
npm start