node-sqlserver-v8 icon indicating copy to clipboard operation
node-sqlserver-v8 copied to clipboard

Keep saying Module not found of sqlserverv8

Open carltin0315 opened this issue 2 years ago • 6 comments

I installed this lib with setting NODE_TLS_REJECT_UNAUTHORIZED with 0. But when I call it, it says:

./node_modules/msnodesqlv8/lib/util.js:5:20 Module not found: Can't resolve '../build/Release/sqlserverv8'

I ensure the sqlserverv8.node exist inside the node_modules. But it just keep saying module not found. msnodesqlv8

I'm using it in a next.js web application and here is my code:

`import sql from "mssql/msnodesqlv8";

const conn = new sql.connect( { database: "db_name", server: "1.1.1.1", driver: "msnodesqlv8", options: { encrypt: false, trustedConnection: true, }, }, (err) => { if (err) { console.log(Error while connecting database: ,${err}); } else { console.log(connected to database); } } ); export { conn }; `

carltin0315 avatar Jun 19 '23 06:06 carltin0315

I am also seeing this, the issue began when I upgraded Node to LTS (18.16.1).

I got it to work by going into /lib/util.js and changing the require path for cppDriver to include the file extension. So, changing '../build/Release/sqlserverv8' to '../build/Release/sqlserverv8.node'. Not a legit solution, but good enough for my current purposes and maybe good info on what's not working here.

DaveMcNamara avatar Jun 23 '23 18:06 DaveMcNamara

by going into /lib/util.js and changing the require path for cppDriver to inc

Not work for me. It gives me same error of Module not found: Can't resolve '../build/Release/sqlserverv8'

carltin0315 avatar Jun 26 '23 05:06 carltin0315

It didn't work for me either. I can even delete the util.js file, change whatever inside it, clean npm cache and it still fail to compile with same error. is there any other cache I should clean?

henriquedpn avatar Jul 15 '23 10:07 henriquedpn

what is the right approach after successfully npm install? I think docs are too much information and misleading too

muhaimincs avatar Jul 17 '23 13:07 muhaimincs

looks similar to this issue which can be fixed as described

TimelordUK avatar Nov 16 '23 20:11 TimelordUK

https://github.com/TimelordUK/node-sqlserver-v8/releases

look at release notes this should now sort out NextJS based problems

TimelordUK avatar Nov 19 '23 17:11 TimelordUK