I am trying to deploy Adonisjs 5 API using on Digital Ocean. I encountered an error relating to .env. Below is the code bbase of the error.
gmh@ubuntu-gmh:~/www/gmh-api$ cd build
gmh@ubuntu-gmh:~/www/gmh-api/build$ node ace migration:run --force
Exception
E_MISSING_ENV_VALUE: Missing environment variable "DB_CONNECTION"
gmh@ubuntu-gmh:~/www/gmh-api/build$
I have DB_CONNECTION declared in .env file
PORT=3333
HOST=127.0.0.1
NODE_ENV=production
DRIVE_DISK=local
DB_CONNECTION=mysql
Below is the database configuration code:
connection: Env.get('DB_CONNECTION'),
connections: {
/*
|--------------------------------------------------------------------------
| MySQL config
|--------------------------------------------------------------------------
|
| Configuration for MySQL database. Make sure to install the driver
| from npm when using this connection
|
| npm i mysql2
|
*/
mysql: {
client: 'mysql2',
connection: {
host: Env.get('MYSQL_HOST'),
port: Env.get('MYSQL_PORT'),
user: Env.get('MYSQL_USER'),
password: Env.get('MYSQL_PASSWORD', ''),
database: Env.get('MYSQL_DB_NAME'),
},
n/b: mysql is installed on the nginx server on Digital Ocean
Pls guys, an helpfull insight is welcome.
I tried running:
node ace migration:run --force
inside the build folder root, afterwhich i got:
Exception
E_MISSING_ENV_VALUE: Missing environment variable "DB_CONNECTION"