0

I'm trying to install MySQL support for NodeJS (v0.6.9) on Ubuntu. I'm issuing the following commands:

sudo apt-get install libmysqlclient-dev

I get no errors. I then install the module for Node:

sudo npm install -g db-mysql

Again. No errors. However, I do get what looks like a warning:

Checking for node path                   : not found 

But the installation ends with:

'build' finished successfully (1.504s)
[email protected] /usr/local/lib/node_modules/db-mysql

In my program source I now add:

var mysql = require("db-mysql");

But when I run this, I get the following error:

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: Cannot find module 'db-mysql'
    at Function._resolveFilename (module.js:334:11)
    at Function._load (module.js:279:25)
    at Module.require (module.js:357:17)
    at require (module.js:373:17)
    at Object.<anonymous> (/home/me/projects/node/test.js:4:13)
    at Module._compile (module.js:444:26)
    at Object..js (module.js:462:10)
    at Module.load (module.js:351:31)
    at Function._load (module.js:310:12)
    at Array.0 (module.js:482:10)

It obviously can't find the db-mysql module.

3
  • Is this helping ? stackoverflow.com/questions/7076529/… Commented Nov 18, 2012 at 23:58
  • I don't want to install from source if I can help it. I update Node through apt-get and I'd like the modules I use to follow a similar pattern. Commented Nov 19, 2012 at 0:21
  • Can you install db-mysql locally instead? npm install db-mysql from your project directory. Commented Nov 19, 2012 at 0:46

1 Answer 1

1

Node.js does not looking for modules in global modules folder (/usr/local/lib) by default.

You need to install your module locally by npm install db-mysql.

You can read more about module resolving strategy here: http://nodejs.org/api/modules.html#modules_loading_from_node_modules_folders

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.