Asked 7 years ago
8 Feb 2017
Views 2040
samir

samir posted

Error: Cannot find module in Node JS


module.js:457
    throw err;
    ^

Error: Cannot find module  
    at Function.Module._resolveFilename (module.js:455:15)
    at Function.Module._load (module.js:403:25)
    at Module.runMain (module.js:590:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3





var mysql      = require('mysql');
var connection = mysql.createConnection();

Mitul Dabhi

Mitul Dabhi
answered Nov 30 '-1 00:00

basically you are using non installed module .

try to install that module , from the code i can find mysql module you need to install

npm i mysql

it will probably solve your problem
shyam

shyam
answered Nov 30 '-1 00:00

i daily found this "Error: Cannot find module in Node JS " because when i try to start work run directly command node app in root directory where there is no app.js and i got this "Error: Cannot find module in Node JS "

so "Error: Cannot find module in Node JS" , means not always we forget to install module , but it also arise when you try to access file you dont have in the current directory .
Post Answer