typeorm: Cannot set property EntityManager of # which has only a getter

Issue type:

[x] bug report

Database system/driver:

[x] postgres

TypeORM version:

[x] latest

Steps to reproduce or a small repository showing the problem:

TypeError: Cannot set property EntityManager of #<Object> which has only a getter
    at Object.<anonymous> (/usr/src/app/node_modules/typeorm/index.js:120:23)
    at Module._compile (internal/modules/cjs/loader.js:1185:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1205:10)
    at Module.load (internal/modules/cjs/loader.js:1034:32)
    at Function.Module._load (internal/modules/cjs/loader.js:923:14)
    at Module.require (internal/modules/cjs/loader.js:1074:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/usr/src/app/lib/index.js:5:19)
    at Module._compile (internal/modules/cjs/loader.js:1185:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1205:10)

Somehow getting this random error now and have. Literally tried rolling back my code and everything. Any suggestions where to look?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 112
  • Comments: 40 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Edit your package.json at your project root directory to avoid using latest version of tslib

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

Temporary workaround: npm i tslib@1.11.2 --save and remove ^ before the version in package.json:

...
"tslib": "1.11.2",
...

tslib updated which is exposing a pre-existing issue with double-exporting symbols:

TSLib behavior change and other folks having problems with it have been reported there:

@possible819 you’ve saved my time.

Still diagnosing but in case this helps someone, it appears that even locking to tslib@1.11.2, a clean yarn install will still manifest this error. However a clean npm install will allow my app to run fine. Very odd.

I have the same problem. This is fantastic!

Okay, I fixed it and with yarn!!! After adding tslib@1.11.2, I checked the version and the syntax to be correct in the package.json file. Then, as it is stated above I also added, at the end of the package.json file, this:

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

Important: If you install tslib@1.11.2 with npm, make sure to remove the package-lock.json file. For some reason, it also asked my to re-install reflect-metadata.

Finally, I fixed it and everything works correctly right now! Thank you for the support guys.

Lo que hice fue regresar a mi versión de typeorm a la versión 0.2.4. El problema se fue enseguida.

sí, el mío también, pero ¿tuvo alguna otra solución que funcione con la última versión de typeorm?

Nada amigo, por el momento esa es la unica solución que he podido encontrar.

Lo que hice fue regresar mi versión de typeorm a la version 0.2.4. El problema se fue enseguida.