Open mosilver opened 4 years ago
Is it an .ormconfig.ts
you pasted? It looks like TypeORM couldn't find it
It's not super clear from the docs, but basically the nestjs-admin
command relies on TypeORM being able to discover your configuration automatically. Which means you have 2 options for it to work:
.ormconfig{.json, js, ts...}
or .env
, TypeORM docs here) in your root folder (next to package.json
)npx nestjs-admin
(TYPEORM_URL should be enough)I had the ormconfig.ts in src folder, so I moved it to the root of project near package.json but the effect is still the same - standard app is starting (left terminal) adding admin fails (right terminal), I attach the full content of config as well:
https://www.dropbox.com/s/u5kh259y3oa8uy7/localization.jpg?dl=0 https://www.dropbox.com/s/7njy07hvu9ag2w7/error.jpg?dl=0
hi i have the same error, i follow the tutorial in https://nestjs-admin.com/docs/install
Unable to connect to the database. Retrying (1)...
QueryFailedError: Table 'adminuser' already exists
According to the documentation I have installed package, added module admin, admin entity, the db migration that added adminuser table and then I try to add the admin user with command:
$npx nestjs-admin createAdminUser
and I get error:
Error: Could not connect to your database to create an admin user. Make sure you have an ormconfig file with a default connection or that your environment variables are set (see https://github.com/typeorm/typeorm/blob/master/docs/using-ormconfig.md). at Function. (C:\api\node_modules\nestjs-admin\bin\cliAdmin.module.ts:18:13)
at Generator.throw ()
at rejected (C:\api\node_modules\nestjs-admin\dist\bin\cliAdmin.module.js:5:65)
at processTicksAndRejections (internal/process/task_queues.js:94:5)
but the ormconfig works when I just start the app (after table remove as I get as well issue with: [ExceptionHandler] ER_TABLE_EXISTS_ERROR: Table 'adminuser' already exists +1ms QueryFailedError: ER_TABLE_EXISTS_ERROR: Table 'adminuser' already exists )
my config:
`const AdminUser = require('nestjs-admin').AdminUserEntity;
const config: ConnectionOptions = { type: 'mysql', host: 'localhost', port: 3306, username: 'root', password: '', database: 'suplineo', entities: [dirname + '//.entity{.ts,.js}', IngredientEntity, AdminUser], //entities: ["src//.entity{.ts,.js}"], synchronize: true, migrationsRun: false, logging: true, logger: 'file', migrations: [dirname + '/migrations/*/{.ts,.js}'], cli: { "migrationsDir": "src/migrations" } };`