Reputation: 2647
I'm trying to port a nodejs MS SQL Server application to deno. I'm using the node compatibility library to allow the use of npm mssql package:
import { createRequire } from "https://deno.land/std/node/module.ts";
const require = createRequire(import.meta.url);
const sql = require('mssql')
async () => {
try {
await sql.connect('mssql://user:pwd@host/database')
const result = await sql.query`select * from the_table`
console.dir(result)
} catch (err) {
console.log('Error:', err)
}
}
However I'm getting an error:
error: Uncaught Error: Cannot find module 'crypto' Require stack:
- C:\WORK\LEARN\DENO\node_modules\tedious\lib\connection.js
- C:\WORK\LEARN\DENO\node_modules\tedious\lib\tedious.js
- C:\WORK\LEARN\DENO\node_modules\mssql\lib\tedious.js
Note: upgrading to the latest version of mssql helped, getting a different error, 'unable to find module tty', which I think I can figure out.
Upvotes: 2
Views: 1184
Reputation: 1
import sql from "npm:mssql";
(async () => {
try {
await sql.connect('Server=xxx.xxx.xxx.xxx,1433;Database=yyyyyyyyy;User Id=zz;Password=aaaaa;Encrypt=true');
const result = await sql.queryselect * from Accounts
;
console.log(result.recordsets);
} catch (err) {
console.log(Error: ${err}
)
}
})();
Upvotes: 0
Reputation: 1056
The crypto library internal to Node is used internally by the mssql library, however this isn't fully ported to Deno yet as you can see here
https://deno.land/[email protected]/node
Upvotes: 3