Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't init TypeORM project

Tags:

npm

typeorm

I'm trying to create a new TypeORM project and have run the following commands, according to the TypeORM documentation:

npm install typeorm -g

typeorm init --name MyProject --database postgres

I get this error:

TypeError: Cannot set property EntityManager of #<Object> which has only a getter
at Object.<anonymous> (~/.npm-global/lib/node_modules/typeorm/index.js:120:23)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (~/.npm-global/lib/node_modules/typeorm/commands/SchemaSyncCommand.js:4:15)
at Module._compile (internal/modules/cjs/loader.js:778:30)

I get the same error even if I just try to run

typeorm
like image 205
Andreas Winther Moen Avatar asked May 13 '20 16:05

Andreas Winther Moen


2 Answers

Add

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

to your package json, tslib 1.12 breaks typeorm

like image 60
user840250 Avatar answered Nov 13 '22 15:11

user840250


The workaround that did it for me was this:

npm i [email protected] --save and remove the ^ before the version in package.json of my project.

The open issue can be found here

like image 23
Noah Anderson Avatar answered Nov 13 '22 14:11

Noah Anderson