Database.js not found using forest CLI

Feature(s) impacted

Forest CLI does not find database.ts file when using forest schema:update command after migrating to Typescript (it looks for database.js instead).

Observed behavior

We are trying to migrate our Sequelize files to Typescript using [this doc]( 2).
We migrated middlewares/forestadmin, models/index, config/databases and some model files to Typescript, but when we try to use the command forest schema:update in our console, it is followed with this error :
× The configuration file "/Users/userName/projectName/backoffice/config/databases.js" does not exist.

I found this issue that looked similar but the solution did not work.

Expected behavior

forest schema:update generates new files if there is a new table in the database.





Hello @Fannie_Yan,

Is it working when you turn databases.ts back to databases.js?


Hello @Fannie_Yan,

If you look at the inline help for the schema:update command, you will find the config option.
Can you please try it with the path to your database file and see if all is working directly?

> forest schema:update --help
Refresh your schema by generating files that do not currently exist.

  $ forest schema:update

  -c, --config=config                    [default: config/databases.js] Database 
                                         configuration file to use.

  -o, --outputDirectory=outputDirectory  Output directory where to generate new 

Hello, thanks to you two for your help !

@Sliman_Medini forest CLI does find databases.js

@anon79585656 Using config option works !

Although, now, I have a new unexpected error when I run the command with config option (it actually is the same error as when I turn databases.ts into databases.js)
× An unexpected error occurred. Please reach out for help in our Developers community ( or create a Github issue with following error: Cannot use import statement outside a module


Reading the Forest CLI code, I am not sure having the databases file in TypeScript is properly supported.

Using require statements in place of imports might fix the issue here.
If not, can you leave this file in plain Javascript for now?

I’ll share this with the team.