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
Add Yarn workspaces supports for ormconfig.js location #2805
Comments
Any update on this? |
I created a repo reproducing the problem: https://github.com/aaronjensen/typeorm-monorepo-repro Many projects use https://github.com/davidtheclark/cosmiconfig. Perhaps typeorm could as well? |
A workaround for the time being is the use of a Nevertheless I'd appreciate support for |
What is the workaround for this? Just drop the JSON file into the project root? |
If someone is interested in workaround, check out here : inxilpro/node-app-root-path#31 (comment) |
Hi, i got same issue with this config. Then i make a connection helper to read the config file based on server package because i use monorepo in my project.
Then call the function to initiate connection config
|
Any update on this? |
Does anyone have idea how to fix this better than #2805 (comment) |
nohoist needed b/c typeorm/typeorm#2805.
nohoist needed b/c typeorm/typeorm#2805.
nohoist needed b/c typeorm/typeorm#2805.
nohoist needed b/c typeorm/typeorm#2805.
ormconfig.js location is inaccurate with yarn workspace. typeorm/typeorm#2805
nohoist needed b/c typeorm/typeorm#2805.
Looks like Seems like this issue is resolved? |
we've had that version since 2019 - if it's been a problem since then I think there's other issues. However, if you've confirmed that it's working, yay! We can maybe close this out? |
I take the silence as "it works". With that in mind I'm closing it. Feel free to reopen or open a new issue if I've misunderstood. |
TypeORM: 0.2.36 Repo with Yarn PnP Issue about supporting yarn workspaces in app-root-path still open inxilpro/node-app-root-path#31. |
inxilpro/node-app-root-path@20420ae This doesn't add support for pnpm? |
Perhaps it does, but root of the issue not pnpm (I am not even sure it is related, but didnt check). it is monorepo with workspaces which gives a problem. I think having plain old node_modules with modules hoisted to the root folder will trigger same error. so, having that structure:
app-root-path will give |
Is there a way to specify the path of the file to the underlying function to load the connection options in the getConnectionOptions function? IMO there should be a loadConnectionOptions that has a the file to load as an argument, or an overload of the getConnectionOptions function. |
Actually, the base path can already be passed to the ConnectionOptionsReader, see this example: async function findPackageRoot(): Promise<string | null> {
for (const dir of module.paths) {
if (await fs.stat(dir).catch((e) => null)) {
return path.dirname(dir);
}
}
return null;
}
async function startApp() {
// read connection options from ormconfig file (or ENV variables)
const connectionOptionsReader = new ConnectionOptionsReader({
root: await findPackageRoot(),
});
// do something with connectionOptions,
// for example append a custom naming strategy or a custom logger
// Object.assign(connectionOptions, { namingStrategy: new MyNamingStrategy() });
const connectionOptions = await connectionOptionsReader.get('default');
// create a connection using modified connection options
const connection = await createConnection(connectionOptions);
} |
Looks like deprecated hoisting does no longer work in my yarn v3.1.0. I found following simple workaround:
Note that I made tools/typeOrmCli.ts wrapper file with following contents:
This will call the cli from the folder of application and build correct path string for migration file. |
Issue type:
[ ] question
[ ] bug report
[x] feature request
[ ] documentation issue
Database system/driver:
[ ]
cordova
[ ]
mongodb
[ ]
mssql
[ ]
mysql
/mariadb
[ ]
oracle
[x]
postgres
[ ]
sqlite
[ ]
sqljs
[ ]
react-native
[ ]
expo
TypeORM version:
[x]
latest
[ ]
@next
[ ]
0.x.x
(or put your version here)Steps to reproduce or a small repository showing the problem:
The
ormconfig.js
location is determined by app-root-path, when using yarn workspaces, it's not accurate anymore.Given
After
yarn
, it createsSo it reads
ROOT/ormconfig.js
instead ofROOT/server1/ormconfig.js
Possible solution: try
process.cwd()
firstThe text was updated successfully, but these errors were encountered: