While trying to establish a connection to MySQL using typeorm in TypeScript, an error occurred indicating that the repository could not be found

The server is currently listening on port 3000 and my MySQL database has been initialized.

RepositoryNotFoundError: It appears there is no repository for the entity "User" in the current "default" connection. 
  Are you sure this entity is registered?

message: 'No repository for "User" was found. Looks like test.js) 
{his entity is not registered in the current "default" connection?'                 
 his entity is not registered in the current "default" connection?'}

Any suggestions on how to resolve this issue?

Answer №1

After facing a similar issue, I discovered that the root cause could be attempting to utilize the getRepository method before establishing a connection with the database.

To resolve this issue, I implemented an async function utilizing

const connection = await createConnection()
, followed by
await connection.driver.afterConnect().then()
, and then continued with configuring routes.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is there a way to access and read an Excel file stored within the assets folder using Angular?

I need assistance converting an excel file to a JSON format. My excel file is currently stored in the assets folder, and I am looking for guidance on how to access it from app.component.ts. Any help would be greatly appreciated! ...

What is the best way to extract the text from dynamically created buttons using JavaScript?

Is there a way to retrieve the text displayed on a button when it is clicked? The buttons are created in a document fragment and then added to the page. I have attempted to create a function that captures the text, but when I click a button, nothing shows ...

Invoking a PHP script within a div by clicking a button with the help of AJAX requests

I am currently utilizing an ajax script to call a php page named "MAINPAGE.PHP" by clicking on a button. This page contains an echo statement within a div with the id "YOURDIV". However, it seems that it's not properly calling the "MAINPAGE.PHP". Belo ...

Running Angular without dependencies causes it to malfunction

I recently ventured into the world of AngularJS and started by creating a module without any services or factories. Everything was running smoothly until I decided to introduce services and factories into my code. Suddenly, things stopped working. Here is ...

Issue encountered in Ionic/React/Typescript - Incorrect props supplied to React.FC<'erroneous props provided here'>

Having struggled with this issue for a while now without any success, I have searched through numerous questions here but none seem to address my specific case. Therefore, I kindly request your assistance. I am encountering difficulties passing props thro ...

Upon initiating npm start in my React application, an error was encountered: internal/modules/cjs/loader.js:834

Upon downloading my React course project, I proceeded to install dependencies and run npm start. To my dismay, I encountered the following error: PS C:\Users\Marcin & Joanna\Desktop\react-frontend-01-starting-setup> npm start &g ...

Can an event be passed from one Vue.js component to another without relying on a global EventBus?

I have two independent components that are not directly related to each other. However, I want them to be able to communicate so that when an event is triggered in one component, the other component can respond accordingly. For example, let's conside ...

Get information about mailchimp mailing lists using ajax requests with the iron-ajax element in Polymer

Struggling to access the mailchimp API and display list details? Unsure of how to send authentication credentials to retrieve the information you need? Here are a few attempts that have been made so far: <iron-ajax auto url='https://us3.ap ...

What could be causing the show button to change its style every time I click it?

I'm a beginner in the world of JavaScript. I have been working on customizing the "show more" button and encountered an issue. I managed to add text and a down arrow below the button, but when I click it, another button labeled "I don't know how ...

How can I apply a jquery method to a variable when JavaScript already has a method with the same name?

Is it possible to call the .which function on a character without needing to differentiate between browser types by using the jQuery .which method, which supposedly normalizes for browser discrepancies? I know that the inherent javascript method is also ...

Ways to pass a message from index.html to a Vue.js 3 instance

Picture this scenario: You have a Vue index.html file that also loads a custom script: <!DOCTYPE html> <html lang="en"> <head> ... ... <script type="text/javascript"> languagePluginLoader.then(fun ...

Once I incorporated Bootstrap into my project, I noticed a noticeable white space between the div elements

Welcome to My Code Playground I was sailing smoothly with my project until I decided to include Bootstrap. Seems like there's something missing in the details, so here I am reaching out. If you spot the issue, please feel free to correct my code. &l ...

What causes the difference in behavior between using setInterval() with a named function as an argument versus using an anonymous function?

I can't seem to figure out why using the function name in setInterval is causing issues, while passing an anonymous function works perfectly fine. In the example that's not working (it's logging NaN to the console and before the first call, ...

Where should custom PHP code be placed in Prestashop 1.7.5?

Currently, I am facing the challenge of incorporating a custom PHP code snippet into Prestashop's file structure so that it is accessible on all pages such as the cart, categories, and CMS pages. After some research, I have found suggestions to place ...

Optimal approach for integrating an ionic mobile app with Django to streamline form processing

Currently in the process of developing a mobile application with ionic technology. In the case of a traditional django website, we typically create context within the view and pass it to the template, where the HTML is displayed using various methods such ...

Load divs, images, or scripts as they enter the viewport

Upon visiting the website , you may notice that certain elements are loaded only when they enter the viewport. I am interested in learning how to implement this feature and am curious about the specific JavaScript or CSS3 techniques utilized for achieving ...

Expansive full screen image proportions

Is there a way to showcase an image on the entire screen without distorting it, while maintaining its aspect ratio in either HTML or Javascript? The desired outcome is for the image to be centered and: - Have a height of 100% and a width of x% (where "x" ...

Display an array in Angular HTML by calling a function

I am currently working on an app that involves displaying cars retrieved from a database. Each car has a string of tags separated by commas, and I have created a function to split these tags into individual words and display them as tags. However, I am str ...

Is it possible to determine the location of the "phantom image" while moving an object?

Is there a method to retrieve the location of the ghost image when an element is dragged? This is how the scenario is set up: <div id="test" v-on:dragstart="dragStart" v-on:drag="dragging" draggable="true" v-on:drop="drop" v-on:dragover="allowDrop"> ...

Having trouble accessing undefined properties? Facing issues with the latest Angular version?

Why am I encountering an error and what steps can be taken to resolve it? Currently using the latest version of Angular. ERROR TypeError: Cannot read properties of undefined (reading 'id') Here is the JSON data: { "settings": [ { ...