Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set property EntityManager of #<Object> which has only a getter #6054

Closed
AuspeXeu opened this issue May 12, 2020 · 40 comments
Closed

Comments

@AuspeXeu
Copy link

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?

@tombh
Copy link

tombh commented May 12, 2020

Seeing this as well on new CI builds only in the last few hours. Hadn't made any changes at all. So maybe it's a dependency updated somewhere?

@mgabeler-lee-6rs
Copy link

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:

@IncoCode
Copy link

IncoCode commented May 12, 2020

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

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

@wuzi
Copy link

wuzi commented May 12, 2020

Had this problem today when installing dependencies, rolled back to a previous package-lock.json and fixed the problem.

@ggaj
Copy link

ggaj commented May 12, 2020

I have some problem...

some solution?? ... for us in new version...

Thanks

@leon-developer-br
Copy link

I have the same problem.

Any solution? Thx

@alexey-nobody
Copy link

I have the same problem. This is fantastic!

@eddieajau
Copy link

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.

@alexey-nobody
Copy link

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

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

This is work fine or use in CI TypeORM from project (not installed globally)

@kyleamazza
Copy link

Also can confirm that npm i tslib@1.11.2 and removing the ^ works when installed as a local dependency.

@felipellrocha
Copy link

I am also having the same issue. The workaround, however, is not working for me

@SevenElement
Copy link

I have the same problem.

@felipellrocha
Copy link

Ehr, I can confirm that npm works fine, yarn breaks. Weird.

@possible819
Copy link

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

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

@lotstar87
Copy link

@possible819 you've saved my time.

@PodaruDragos
Copy link

you can keep typescript 3.9.2
and just add tslib 1.11.2

this seems to work

@georgekrax
Copy link

georgekrax commented May 13, 2020

Have the same problem. I could not solve my problem, either if I used npm or yarn, and added with the correct syntax the version in the package.json file. After waking up, I had to re-configure my computer, because of Ubuntu, and after-hours seeing this error. Please help!

@georgekrax
Copy link

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.

@KikeMendez
Copy link

@possible819 Thanks legend!!

@georgekrax
Copy link

Your welcome. Always nice to help, if I have the solution why I do not let others to solve their issues too!

@sephirothmk
Copy link

Is there a way to fix this without using yarn?

@ivansieder
Copy link

Also can confirm that npm i tslib@1.11.2 and removing the ^ works when installed as a local dependency.

@sephirothmk you could - in the meantime - install tslib manually and fix it to the 1.11.2 version.

@rrrix
Copy link

rrrix commented May 13, 2020

Yarn users can also try a semver range that explicitly excludes tslib@1.12.0 - assuming this gets fixed in tslib@1.13.0 (if not, reminding you to check again).

Also, a friendly reminder that it's never really a good idea to pin a version of a core library (like tslib) forever until the end of time. You might need those updates eventually!

  "resolutions": {
    "tslib": "^1 <1.12.0 || ^1.13.0"
  },

@offboarded-x233534
Copy link

offboarded-x233534 commented May 13, 2020

Ok came here hours ago and nothing worked.
Until I realized there was a broken migration which we run automatically during startup with
await connection.runMigrations()
And the error is totally not related to the broken migration but it was it. So check for you last migration files and maybe the error lies there. Cost me hours fiddling with all the dependency versions. And somehow it has partly to do with typeorm versions and this tslib, but this not the whole story.

mdurling pushed a commit to lacuna-tech/mds-core that referenced this issue May 13, 2020
@xuemengfei
Copy link

ts 3.8 + tslib 1.13.0 works for me

microsoft/tslib#102 (comment)

harjis added a commit to harjis/graphs-folders-microservice that referenced this issue May 14, 2020
@mdurling
Copy link

tsc 3.9.2 + tslib 2.0.0 seems to resolve

@JuniorTrojilio
Copy link

tsc 3.9.2 + tslib 1.11.2 resolved for me for now

@georgekrax
Copy link

tslib@^2.0.0 works fine for me, with yarn & TypeORM.

@ramosht
Copy link

ramosht commented Jun 4, 2020

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

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

Worked for me using yarn!

@dyatko
Copy link

dyatko commented Jun 14, 2020

Still reproducible:

typescript@3.9.5
tslib@2.0.0
typeorm@0.2.25

@SpencerKaiser
Copy link

SpencerKaiser commented Jul 21, 2020

For what it's worth, I deleted node_modules and package-lock.json and re-ran npm i and the issue resolved itself ¯\_(ツ)_/¯

@imnotjames
Copy link
Contributor

imnotjames commented Oct 5, 2020

Cannot reproduce this issue. Seems to be fixed.
Closing.

@degoprisss
Copy link

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

@ks221197
Copy link

ks221197 commented Apr 11, 2022

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

yes mine too but did you have any other solution which work with typeorm latest version.

@Chethana-it
Copy link

Same issue is with me. Cannot set property metadata of # which has only a getter

@degoprisss
Copy link

degoprisss commented Apr 13, 2022

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.

@wsr2k2
Copy link

wsr2k2 commented May 14, 2022

"tslib": "1.11.2"

here too

@FrouniS
Copy link

FrouniS commented May 21, 2022

getting tslib with npm didn't fix it for me , still having the same error

@a7urag
Copy link

a7urag commented Feb 8, 2023

Changed import to
import * as typeorm from 'typeorm/globals';

@sespinoza-dev
Copy link

This bug can still be reproduced.

typeorm@0.3.17
typescript@5.1.6
tslib@2.6.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests