Error: No connection options were found in any orm configuration files
Solution 1
Hello I had the same error for one day, but I had to explicitly show the path of the config file
This was my current typeorm
package.json
script command
"typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js"
i changed it to
"typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js --config src/config/postgres.config.ts"
not how I explicitly set the path of the config file that I am using, no matter which extension you are using, either .js
, .ts
, or .json
here is the example of my config file
// postgres.config.ts
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
export const pgConfig: TypeOrmModuleOptions = {
type: 'postgres',
host: process.env.POSTGRES_HOST,
port: parseInt(<string>process.env.POSTGRES_PORT),
username: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD,
database: process.env.POSTGRES_DATABASE,
entities: ['dist/src/modules/**/entities/*.entity.js'],
synchronize: true,
migrations: ['dist/src/db/migrations.js'],
cli: { migrationsDir: 'src/db/migrations' },
};
Hope it gonna help
Solution 2
From the picture you posted, you misplaced the ormconfig.json
in ./src directory which path maybe your_project/src/ormconfig.json
.Please move it to root directory of project(path: your_project/ormconfig.json
) will work out!
Solution 3
You can try use the following instead
npx typeorm migration:create -n migrationName
ashkufaraz
I love God and PHP and Jquery and C# and Process Maker and ;) I need a job remotely... [email protected] Resume +989135128163
Updated on July 25, 2022Comments
-
ashkufaraz almost 2 years
I want connect to oracle with typeorm
createConnection().then(async connection => { const app = express(); const userRepository = getRepository(User); const users = await userRepository.find(); console.log(users); app.listen(3000); }).catch(error => console.log("xxx",error));
ormconfig.json
is in./Myproject/ormconfig.json
but say error :Error: No connection options were found in any orm configuration files.With these settings , I was already connected to the database with the oracledb.
Please help me
UPDATE
I generate project with this
typeorm init --name MyProject --database oracle
. This is typeorm default structure. -
ashkufaraz over 3 yearsI moved ormconfig.json to ./src directory but it still gives an error
-
spike 王建 over 3 yearsroot not ./src! The current file path maybe
your_project/src/ormconfig.json
.You should move it toyour_project/ormconfig.json
@ashkufaraz -
ashkufaraz over 3 yearsIn the image ormconfig.josn is in the root directory(MyProject/ormconfig.json)
-
303 over 3 yearsNo, it's not. It's in
./src
. You have to move it one level up. -
Marko Marchisio over 2 yearsthis really helped? because i installed it globally. Should i install it as npm i --save typeorm?
-
Sh031224 over 2 yearsYes. I’m solved this problem by removing global typeorm.
-
Macdonald over 2 yearsThis only works for creating migration files and not actually running the migrations.
-
HonorableTones over 2 yearsTHIS is what solved the problem after a long search.