无法读取未定义的属性(读取 'singleton')-Adonisjs

Cannot read properties of undefined (reading 'singleton') - Adonisjs

tender注册单例服务时出错

我正在使用 IocContract

AppProvider

export default class AppProvider {
  constructor(
    protected app: ApplicationContract,
    protected $container: IocContract
  ) {}

  public register() {
    // Register your own bindings
    this.$container.singleton(
      'Front/RegraService',
      () => new RegraService()
    )
  }

错误

Cannot read properties of undefined (reading 'singleton')

export default class AppProvider {
  constructor(protected app: ApplicationContract) {}

  public register() {
    this.app.container.singleton('Front/RegraService', () => new RegraService())
  }
}