TypeORM Errors Handbook for Beginners

Burcu S
2 min readDec 7, 2020

--

This is a quick guide for get rid of some errors related to TypeORM. Yes it’s really really quick… It contains an error message title and it’s solution. All solutions are based on my experiences :)

#1: Experimental support for decorators is a feature that is subject to change in a future release

Add "experimentalDecorators": true and "strictPropertyInitialization": false lines to your compilerOptions which is in your tsconfig.json.

#2: ColumnTypeUndefinedError

Add “emitDecoratorMetadata”: true line to your complerOptions which is in your tsconfig.json.

#3: UnhandledPromiseRejectionWarning: DriverPackageNotInstalledError

You should install your database package if you use mysql you can run

$npm install mysql — save command.

#4: UnhandledPromiseRejectionWarning: Error: ER_ACCESS_DENIED_ERROR:

Probably your connection informations are wrong. Check them and if you’re sure all informations are correct then check your database management service login options.

#5: “Connection “default” was not found” Error

Back to the #4. If it’s not probably you’re trying to do some operatios when connection is not initialized. Also you can try solution of #6.

#6: “RepositoryNotFoundError: No repository for “xxx” was found.

It seems like we couldn’t create a repository cause our entity is not defined on our connection context.

First reason: it may causes by incorrect entity class path in the import line. Check your entity class path.

Second and strong reason: You know getting connection is an async operation. So maybe you trying to add before your connection established.

If you do something like this:

getConnection().getRepository(Xclass).save(xinstance)…

Add there connection() method for get a connection promise:

getConnection().connection().then(connection => connection.getRepository(Xclass).save(xinstance)….

That’s all for now. I’ll update this article if I get a new error.

--

--

Burcu S

Flutter Developer, Lover & Learner | Computer Engineer | For contact: linkedin.com/in/burcus/