MSSQL - TypeError: _this.driver.Connection is not a constructor
See original GitHub issueEither there’s something going on, or the error message isn’t helpful. 😃
My connection works with the base mssql, but not with Knex. Sample code to reproduce (run with babel-node):
import mssql from 'mssql';
import knex from 'knex';
require('dotenv').config();
const test = async () => {
try {
await mssql.connect(process.env.DATABASE_URL);
const result = await mssql.query`select 1 as dbIsUp`;
console.log(result.recordset);
mssql.close();
} catch (err) {
console.log(err);
}
};
test();
const db = knex({
client: 'mssql',
connection: process.env.DATABASE_URL,
debug: true,
});
db.raw('select 1 as dbIsUp').then((values) => {
// there is a valid connection in the pool
console.log(values);
}).catch((err) => {
console.log(err);
});
Expected Result: Connects without errors, OR error message that helps troubleshoot issue Actual Result:
knex:pool INFO pool mssql:mssql:client0 - dispense() clients=1 available=0 +0ms
TypeError: _this.driver.Connection is not a constructor
at /mnt/c/Users/Terry/Projects/gohealth/node_modules/knex/lib/dialects/mssql/index.js:135:24
at Promise._execute (/mnt/c/Users/Terry/Projects/gohealth/node_modules/bluebird/js/release/debuggability.js:300:9)
at Promise._resolveFromExecutor (/mnt/c/Users/Terry/Projects/gohealth/node_modules/bluebird/js/release/promise.js:483:18)
at new Promise (/mnt/c/Users/Terry/Projects/gohealth/node_modules/bluebird/js/release/promise.js:79:10)
at Client_MSSQL.acquireRawConnection (/mnt/c/Users/Terry/Projects/gohealth/node_modules/knex/lib/dialects/mssql/index.js:134:12)
at Object.create (/mnt/c/Users/Terry/Projects/gohealth/node_modules/knex/lib/client.js:239:16)
at Pool._createResource (/mnt/c/Users/Terry/Projects/gohealth/node_modules/generic-pool/lib/generic-pool.js:354:17)
at Pool._ensureMinimum (/mnt/c/Users/Terry/Projects/gohealth/node_modules/generic-pool/lib/generic-pool.js:408:12)
at new Pool (/mnt/c/Users/Terry/Projects/gohealth/node_modules/generic-pool/lib/generic-pool.js:157:8)
at Client_MSSQL.initializePool (/mnt/c/Users/Terry/Projects/gohealth/node_modules/knex/lib/client.js:269:17)
at Client_MSSQL.Client (/mnt/c/Users/Terry/Projects/gohealth/node_modules/knex/lib/client.js:116:12)
at new Client_MSSQL (/mnt/c/Users/Terry/Projects/gohealth/node_modules/knex/lib/dialects/mssql/index.js:93:20)
at Knex (/mnt/c/Users/Terry/Projects/gohealth/node_modules/knex/lib/index.js:60:34)
at Object.<anonymous> (/mnt/c/Users/Terry/Projects/gohealth/scratch.js:18:12)
at Module._compile (module.js:571:32)
at loader (/mnt/c/Users/Terry/Projects/gohealth/node_modules/babel-register/lib/node.js:144:5)
knex:pool INFO pool mssql:mssql:client0 - dispense() clients=0 available=0 +54ms
knex:pool INFO pool mssql:mssql:client0 - dispense() clients=0 available=0 +1ms
knex:pool INFO pool mssql:mssql:client0 - dispense() clients=0 available=0 +0ms
[ { dbIsUp: 1 } ]
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (7 by maintainers)
Top Results From Across the Web
MSSQL - TypeError: _this.driver.Connection is not a ... - GitHub
My connection works with the base mssql, but not with Knex. ... ConnectionPool is not a constructor" stack: "TypeError: _this.driver.
Read more >Node js knex and mssql error - 'TypeError: _this.driver ...
I get the error: 'TypeError: _this.driver.Connection is not a constructor'. After a lot of googling, I couldn't find anything with this error ...
Read more >Node js knex and mssql error - 'TypeError - appsloveworld.com
Coding example for the question Node js knex and mssql error - 'TypeError: _this.driver.Connection is not a constructor'-sql-server.
Read more >TypeError: _this.mssql.Connection is not a constructor
Testing the first example in the repo agains MS SQL results in a type error, tested against mysql and that config works, the...
Read more >node-mssql | Microsoft SQL Server client for Node.js
Please note that the connection string with this driver is not the same than tedious and use yes/no instead of true/false. You can...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Still getting this issue on 0.13.0. Unhandled rejection TypeError: _this.driver.Connection is not a constructor at node_modules/knex/lib/dialects/mssql/index.js:135:24 “dependencies”: { “knex”: “^0.13.0” },
It looks like this fix has not been included in a release yet.
There are no schedules, but I’ll make the release before christmas. Maybe this month, maybe some other.