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.
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
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!
You can try use the following instead
npx typeorm migration:create -n migrationName
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With