moccacoders / node-obremap

Laravel's Eloquent ORM for nodejs
https://github.com/moccacoders/node-eloquent
22 stars 9 forks source link

(node:191796) UnhandledPromiseRejectionWarning: Error: You must specify process.env.DB_DRIVER before creating a model. #104

Open nadir1122 opened 3 years ago

nadir1122 commented 3 years ago

according to the documentation I already have placed the following in the .env file

DB_DRIVER = mysql
DB_HOST = 127.0.0.1
DB_USERNAME = user
DB_PASSWORD = pass
DB_NAME=database_name

it is throwing the following error

(node:1620) UnhandledPromiseRejectionWarning: Error: You must specify process.env.DB_DRIVER before creating a model.
    at _default (D:\NodeJsProjects\vue-router-express\wallet\node_modules\@moccacoders\node-obremap\dist\orm\adapters\index.js:31:11)
    at Function.all (D:\NodeJsProjects\vue-router-express\wallet\node_modules\@moccacoders\node-obremap\dist\orm\model.js:113:39)
    at _callee$ (D:\NodeJsProjects\vue-router-express\wallet\controllers\/TestController.js:7:33)
    at tryCatch (C:\Users\Ansari\AppData\Roaming\npm\node_modules\@babel\node\node_modules\regenerator-runtime\runtime.js:63:40)
    at Generator.invoke [as _invoke] (C:\Users\Ansari\AppData\Roaming\npm\node_modules\@babel\node\node_modules\regenerator-runtime\runtime.js:293:22)
    at Generator.next (C:\Users\Ansari\AppData\Roaming\npm\node_modules\@babel\node\node_modules\regenerator-runtime\runtime.js:118:21)
    at asyncGeneratorStep (D:\NodeJsProjects\vue-router-express\wallet\controllers\TestController.js:7:103)
    at _next (D:\NodeJsProjects\vue-router-express\wallet\controllers\TestController.js:9:194)
    at D:\NodeJsProjects\vue-router-express\wallet\controllers\TestController.js:9:364
    at new Promise (<anonymous>)

making config file for the database does not make any change to error

nadir1122 commented 3 years ago

a missing dependency was installed to fix this problem

npm install sync-mysql --save

code change in module file /dist/orm/adapters/index.js

  1. removed if condition in line 30,
  2. changed console.log(global.dev) to console.log(e) for better error detection
P0SEID0N commented 3 years ago

I am having the exact same problem here, except the installation of sync-mysql does not fix the problem. I have insured that my process.env.DB_DRIVER is in fact set to mysql and dotenv is working. Any fix here?

raymundo-salazar commented 2 years ago

I am having the exact same problem here, except the installation of sync-mysql does not fix the problem. I have insured that my process.env.DB_DRIVER is in fact set to mysql and dotenv is working. Any fix here?

@P0SEID0N add the --verbose flag to your command. This will show you the exact error or missing library. Let me know if it worked for you and if not to find a solution together. Greetings

nadir1122 commented 2 years ago

I am having the exact same problem here, except the installation of sync-mysql does not fix the problem. I have insured that my process.env.DB_DRIVER is in fact set to mysql and dotenv is working. Any fix here?

code change in module file /dist/orm/adapters/index.js

removed if condition in line 30, changed console.log(global.dev) to console.log(e) for better error detection

khalidJA commented 3 weeks ago

failure Package