tediousjs / node-mssql

Microsoft SQL Server client for Node.js
https://tediousjs.github.io/node-mssql
MIT License
2.23k stars 466 forks source link

Error when using module #1539

Closed LeoIngramBR closed 1 year ago

LeoIngramBR commented 1 year ago

I'm creating a Power BI Custom Visual using https://www.npmjs.com/package/powerbi-visuals-tools

When using the module mssql I'm having this error. There are other 5 similar errors, but for diferent libs, all inside nome_modules\tedious\lib folder.

ERROR in ./node_modules/mssql/node_modules/tedious/lib/connection.js 12:34-48 Module not found: Error: Can't resolve 'dns' in '[folder]\node_modules\mssql\node_modules\tedious\lib' @ ./node_modules/mssql/node_modules/tedious/lib/tedious.js 59:41-64 @ ./node_modules/mssql/lib/tedious/connection-pool.js 3:12-30 @ ./node_modules/mssql/lib/tedious/index.js 4:23-51 @ ./node_modules/mssql/index.js 1:0-41 @ ./src/visual.ts 2:0-29 82:31-42 83:32-43 @ ./.tmp/precompile/visualPlugin.ts 1:0-42 10:12-18 11:23-29

I have already reinstalled module with npm install and npm install --save

Steps to reproduce the error

  1. Install Power BI Custom Visuals: npm install -g powerbi-visuals-tools
  2. Create new application: pbiviz new ApplName
  3. Open projec folder in VSCode
  4. Install mssql: npm install mssql
  5. Open visual.ts file and add this line inside public update function >>> const sql = require("mssql");
  6. Run application: In terminal, run the command run pbiviz start

Expected behaviour:

When run pbiviz start, the last compiler message will be webpack 5.88.2 compiled successfully in 1895 ms

Actual behaviour:

When run pbiviz start, the last compiler message will be webpack 5.88.2 compiled with 6 errors in 7349 ms

Removing const sql = require("mssql"); from code, I have no errors

Configuration:

Software versions

"mssql": "^9.2.0",
"node": "^20.5.1",
dhensby commented 1 year ago

Please use the issue template

LeoIngramBR commented 1 year ago

Hi, thanks for prompt response. I've included more details

I just notice that using tedious module (https://github.com/tediousjs/tedious) I'm having same error. Maybe is something related to Power BI Custom Visuals.

Thanks.

dhensby commented 1 year ago

Is this running in a true node backend, or is it meant for a browser environment? The dns module is an inbuilt module in node, so I can't see how else you'd get this error.

dhensby commented 1 year ago

What happens if you just try to require the dns module directly, does it work? If not, you'll need to raise an issue with the powerbi-visuals-tools team, as it's not to do with this library why the dns module is not available in the runtime