我有一个Angular(4.3.2)应用程序,我想在其上执行AOT构建.应用程序是使用@angular/cli.我有两个搭建的组件ng generate和一个模块,其中两个都作为声明包含在内:
import {PrivateComponent} from './private.component/private.component';
NgModule({
imports: [
// other imports
PrivateRoutingModule
],
declarations: [
...some other components,
PrivateComponent,
AppTopBarComponent
]
// other stuff
})
export class PrivateModule {}
Run Code Online (Sandbox Code Playgroud)
私有组件也用于模块的路由:
const routes: Routes = [
{path: '', component: PrivateComponent, children: // other components}
]
@NgModule({
imports: [RouterModule.forChild(routes)] // this is the Angular built-in router module
})
export class PrivateRoutingModule {}
Run Code Online (Sandbox Code Playgroud)
注意:路由是如何在另一个模块定义和导入PrivateModule
的AppTopBarComponent内部使用的PrivateComponent's模板.所以两者都被使用和宣布.但是当我使用"node_modules/.bin/ngc" -p tsconfig-aot.json(我在Windows 10上)时,我收到此错误消息:
Cannot determine the …
我有一个基于 NestJS 构建的工作应用程序,它部署在 Heroku 服务器上。它曾经有效,直到最近我所做的每个构建都无缘无故地崩溃了。我做了一些试验,发现该应用程序在TypeOrmModule不包含在AppModule导入中时可以工作,但显然如果没有数据库它就无法使用。配置如下AppModule:
const databaseUrl = process.env.DATABASE_URL;
@Module({
imports: [
TypeOrmModule.forRoot(databaseUrl ? {
type: 'postgres',
url: databaseUrl,
entities: [__dirname + '/**/*.entity{.ts,.js}'],
synchronize: true,
} : {
// configuration for local development
}),
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
Run Code Online (Sandbox Code Playgroud)
我已经检查过并且databaseUrl正在从环境 URL 正确加载。这不是一个剥离的展示示例,这实际上是我部署到 Heroku 的内容 - 我已经删除了所有其他模块以了解问题的根源。如果我现在删除TypeOrmModule该应用程序将不会崩溃。这是 heroku 在崩溃时向我提供的无用日志:
07/08/2020, 12:09:13 PM [NestFactory] 启动 Nest 应用程序... 2020-07-08T12:09:13.300817+00:00 app[web.1]: [Nest] 23
07/08/2020 , 12:09:13 PM …