【问题标题】:TypeORM + TypeError: Cannot set property EntityManager of #<Object> which has only a getterTypeORM + TypeError:无法设置只有 getter 的 #<Object> 的属性 EntityManager
【发布时间】:2020-08-29 21:22:20
【问题描述】:

我有一个 Nest 应用程序由于以下异常而无法启动。我不确定问题的原因。

我创建了this GitHub repository 来复制问题。运行说明在 README 中有详细说明。

错误:

TypeError: Cannot set property EntityManager of #<Object> which has only a getter
    at Object.<anonymous> (/Users/saulo/NodeProjects/typeorm-jest-issues/node_modules/typeorm/index.js:120:23)
    at Module._compile (internal/modules/cjs/loader.js:1147:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Module.load (internal/modules/cjs/loader.js:996:32)
    at Function.Module._load (internal/modules/cjs/loader.js:896:14)
    at Module.require (internal/modules/cjs/loader.js:1036:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/Users/saulo/NodeProjects/typeorm-jest-issues/node_modules/@nestjs/typeorm/dist/common/typeorm.utils.js:5:19)
    at Module._compile (internal/modules/cjs/loader.js:1147:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)

【问题讨论】:

    标签: node.js nestjs typeorm


    【解决方案1】:

    tslib 依赖项似乎存在问题。你可以在这里找到更多信息:

    https://github.com/typeorm/typeorm/issues/6054

    但是启动项目的临时解决方案是将 tslint@1.11.2 添加为依赖项 (yarn add tslib@1.11.2) 并将其添加到您的 package.json 中

     "resolutions": {
       "tslib": "1.11.2" 
     }
    

    【讨论】:

    • 感谢您的回答!这解决了我的问题。我编辑了你的答案并添加了yarn add tslib@1.11.2
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-27
    • 1970-01-01
    • 1970-01-01
    • 2019-04-09
    • 2020-09-26
    • 2021-05-31
    相关资源
    最近更新 更多