The "config.server" property is required and must be of type string

See original GitHub issue

I am trying to connect to ms sql using below code but I am getting error.

const sql = require("mssql");

(async () => {
  try {
    // make sure that any items are correctly URL encoded in the connection string
    await sql.connect("mssql://sa:reallyStrongPwd123@localhost/dbName");
    const result = await sql.query("select * from mytable");
    console.dir(result);
  } catch (err) {
    console.log(err);
    // ... error checks
  }
})();

Expected behaviour:

Should be able to connect

Actual behaviour:

TypeError: The "config.server" property is required and must be of type string.
    at new Connection (/Users/abc/Documents/stuff/projects/xyz/eg-xyz-feed-ingestor/node_modules/tedious/lib/connection.js:342:13)
    at /Users/abc/Documents/stuff/projects/xyz/eg-xyz-feed-ingestor/node_modules/mssql/lib/tedious/connection-pool.js:62:23
    at new Promise (<anonymous>)
    at ConnectionPool._poolCreate (/Users/abc/Documents/stuff/projects/xyz/eg-xyz-feed-ingestor/node_modules/mssql/lib/tedious/connection-pool.js:12:12)
    at ConnectionPool._connect (/Users/abc/Documents/stuff/projects/xyz/eg-xyz-feed-ingestor/node_modules/mssql/lib/base/connection-pool.js:358:10)
    at /Users/abc/Documents/stuff/projects/xyz/eg-xyz-feed-ingestor/node_modules/mssql/lib/base/connection-pool.js:330:19
    at new Promise (<anonymous>)
    at ConnectionPool.connect (/Users/abc/Documents/stuff/projects/xyz/eg-xyz-feed-ingestor/node_modules/mssql/lib/base/connection-pool.js:329:12)
    at Object.connect (/Users/abc/Documents/stuff/projects/xyz/eg-xyz-feed-ingestor/node_modules/mssql/lib/global-connection.js:59:27)
    at /Users/abc/Documents/stuff/projects/xyz/eg-xyz-feed-ingestor/src/core/run.js:6:15

Software versions

  • NodeJS: 14.6.1
  • node-mssql: V7.0.0
  • SQL Server: Microsoft SQL Server 2019 (RTM-CU10) (KB5001090) - 15.0.4123.1 (X64) Mar 22 2021 18:10:24 Copyright © 2019 Microsoft Corporation Developer Edition (64-bit) on Linux (Ubuntu 20.04.2 LTS) <X64>

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:5
  • Comments:10

github_iconTop GitHub Comments

1reaction
victor-cacommented, Sep 26, 2021

in case you encounter this

instead of: mssql://sa:reallyStrongPwd123@localhost/dbName

use Data Source=localhost;Initial Catalog=dbName;User ID=sa;Password=reallyStrongPwd123;trustServerCertificate=true

1reaction
nicoshcommented, May 12, 2021

Can confirm, i have the same issue with v7.0.0, while with v6.2.0 it works fine.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The "config.server" property is required and must be of type ...
I am getting this error TypeError: The "config.server" property is required and must be of type string. Actual behaviour: Configuration: ...
Read more >
TypeError: The "config.server" property is required and must ...
Use directly required configFile , as you are exporting a single const variable object from that file, you don't need to access it...
Read more >
TypeError: The "config.server" property is ... - appsloveworld.com
Coding example for the question TypeError: The "config.server" property is required and must be of type string-sql-server.
Read more >
The "config.server" property is required and must be of type ...
The "config.server" property is required and must be of type string ... I am trying to connect to ms sql using below code...
Read more >
lambda node.js using mssql module - connect error
js program to add a record to an RDS SQL Server database. It returns an error: "config.server" property is required and must be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found