TypeORM + TypeError: Cannot set property EntityManager of #<Object> which has only a getter

柔情痞子 提交于 2021-01-28 13:34:44

问题


I have a Nest application which is not starting due to the following exception. I am not sure what is the cause of the problem.

I created this GitHub repository to replicate the issue. The running instructions are detailed in the README.

The error:

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)

回答1:


There seems to be an issue with the tslib dependency. You can find more info here:

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

But a temporary solution to start your project is to add tslint@1.11.2 as a dependency (yarn add tslib@1.11.2) and to add this to your package.json

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


来源:https://stackoverflow.com/questions/61778771/typeorm-typeerror-cannot-set-property-entitymanager-of-object-which-has-on

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!