-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Glob Pattern Entities Not Resolved #9004
Comments
I am experiencing the same problem on Windows, but there are no issues in the Unix environment with the same configuration. |
I have found the solution. The bug is in the 'glob' package. To make it work with TypeORM, you need to downgrade the 'glob' dependency to version 7.2.0. (how to change it) |
Alternatively, upgrading the glob dep to |
I spent all weekend trying to figure out why an entire application environment stopped working. Today I was debugging TypeORM all the way down to |
I have faced same problem on typeorm 0.3.12 and windows 10. But on linux or mac it's working normally I fixed by overriding
|
Yep. I also have the same problem on typeorm 0.3.12 and windows 11. Overrides helps me too |
+1 to this. Just spent half a day tearing my hairs out. Thanks to @lidroider for the "overrides" trick, I didn't know that. That said, I think the bug is on TypeORM side of things. Glob/minimatch explicitly state in the READMEs:
However TypeORM explicitly calls |
I guess it's already resolved in PR #9768 3 weeks ago. But unfortunately, it's not included in 0.3.12 |
I checked |
Thanks you, i stess about this issue in 3 days |
This also worked for me, but I only overrode typeorm's glob version. I also had to uninstall and reinstall typeorm for the overriden glob version to get installed.
|
Can't believe that I spent hours on this problem. see #9768 |
For Windows specifically, it breaks the usage of glob patterns and can't find the migration files or entities if not overridden. The bug is fixed already but not included in the latest release yet. typeorm/typeorm#9004 (comment)
import { join } from "node:path";
import { DataSource } from "typeorm";
export let dataSource = new DataSource({
type: 'postgres',
host: 'localhost',
port: 5432,
database: 'localdb',
username: 'admin',
password: 'admin',
schema: 'public',
entities: [join(__dirname, '/entities/*.ts').replace(/\\/g, '/')],
migrations: [join(__dirname, '/migrations/*.ts').replace(/\\/g, '/')],
}) this snipped code works for me width Windows,
|
Issue Description
The Directory Exported Classes Loader (
DirectoryExportedClassesLoader.js
) normalizes the path provided to theentities
property on aDataSourceOptions
object. This normalized path changes all forward slashes to back slashes - however, glob is only compatible with forward slashes. Removing thepathNormalize
function fixed my issue.Expected Behavior
Actual Behavior
Steps to Reproduce
My Environment
Relevant Database Driver(s)
aurora-mysql
aurora-postgres
better-sqlite3
cockroachdb
cordova
expo
mongodb
mysql
nativescript
oracle
postgres
react-native
sap
spanner
sqlite
sqlite-abstract
sqljs
sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
The text was updated successfully, but these errors were encountered: