1

I installed mysql.js through npm in Windows 10, however I get mysql module in node.js CLI but not from the command line. I tried the sample code which is given at the official mysql.js website with my local configuration, and it produces a successful connection and a module not found error. I'm at a loss to understand where it's going wrong.

Error: Cannot find module 'mysql'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (d:\projects\prj_nodetest\234.js:1:77)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)

I also tried the file with only one line as:

const mysql = require('mysql');

with the same error.

karel
  • 5,489
  • 46
  • 45
  • 50
Terry KF
  • 19
  • 2
  • Help us help you - share the code and the full error message / stacktrace. – Mureinik Mar 09 '19 at 09:58
  • I use this in command line – Terry KF Mar 09 '19 at 10:01
  • C:\Program Files\nodejs>node d:\projects\prj_nodetest\234.js internal/modules/cjs/loader.js:583 throw err; ^ Error: Cannot find module 'mysql' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15) at Function.Module._load (internal/modules/cjs/loader.js:507:25) at Module.require (internal/modules/cjs/loader.js:637:17) at require (internal/modules/cjs/helpers.js:22:18) at Object. (d:\projects\prj_nodetest\234.js:1:77) I also tried the file only has const mysql = require('mysql'); and resulting in the sam error. Thanks – Terry KF Mar 09 '19 at 10:07
  • It's really hard to make out anything like that. Please [edit] you question and add this information in. Additionally, can you share the contents of your `node_modules` directory? – Mureinik Mar 09 '19 at 10:08
  • Thanks Mureinik. I've already make change on my question – Terry KF Mar 09 '19 at 10:15

0 Answers0