Cannot find module `mysql` node.js
I just ran into the same problem and found it was because the module was installed in:
./node_modules/node-mysql/node_modules/
So, I just moved them all:
mv ./node_modules/node-mysql/node_modules/* ./node_modules/
My node
is installed in C:\some-dir\nodejs-0.10.35\
First navigate to the same directory node
installed: cd C:\some-dir\nodejs-0.10.35
Then npm install mysql
I put my applications in the same directory: C:\some-dir\nodejs-0.10.35\applications\demo.js
It works.
It looks like you might be confused about how npm install
works.
npm install -g mysql
will install globally not locally like you suggest.
npm install mysql
will install locally, putting the module in ./node_modules/mysql
. This means the script you are running needs to be run from the same directory containing node_modules
.
npm install mysql --save
This will update your package.json file.