tengo unos problemas para compilar con aot , estoy usando una repo de angular-universal https://github.com/FrozenPandaz/ng-universal-demo/tree/master/src
la compilacion de aot con npm run build:aot funciona perfectamente con el repo inicial , tengo otro repositorio propio ,en el que trato de adaptar este , cuando agrego la parte del servidor y compilo no hay problema , pero cuando agrego la parte del cliente ./app la que contiene los archivos de angular , me salta el siguiente 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 ....
Tengo entendido que los modulos ngfactory se generan en antes de la ejecucion por el tema de aot ,así que me extraña que aparescan estos errores, pues cuando lo ejecuto sin la parte de mi aplicacion ./app(solo la que tiene por defecto el repositorio) , no me salta ningun problema.
Supongo que tiene que ver con el tema de cannot read property 'text' , buscando lei que era por el tema de typescript , y me recomendaban bajarlo ,sin embargo intente hacer eso , pero rompia varios paquetes.
Este es mi 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"
}
}
Este es la estructura de mis documentos en el directorio ./app
./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
Mi 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 {}
Lo demás,brower-app.module,etc no lo pongo pues esta exactamente como en el repositorio que puse al inicio, además el fallo solo se da cuando trato de compilar con aot , pues cuando compilo con jit , no hay fallo
npm start