2

i have tried following commands,mysql module does not get added to node_module folder,also the code using mysql throw an error.

   Your environment has been set up for using Node.js 0.8.3 (ia32) and NPM

C:\Users\Work>npm install mysql
npm http GET https://registry.npmjs.org/mysql
npm http 304 https://registry.npmjs.org/mysql
npm http GET https://registry.npmjs.org/hashish/0.0.4
npm http 304 https://registry.npmjs.org/hashish/0.0.4
npm http GET https://registry.npmjs.org/traverse
npm http 304 https://registry.npmjs.org/traverse
[email protected] node_modules\mysql
└── [email protected] ([email protected])

C:\Users\Work>npm install [email protected]
npm http GET https://registry.npmjs.org/mysql/2.0.0-alpha3
npm http 304 https://registry.npmjs.org/mysql/2.0.0-alpha3
npm http GET https://registry.npmjs.org/require-all/0.0.3
npm http 304 https://registry.npmjs.org/require-all/0.0.3
[email protected] node_modules\mysql
└── [email protected]

C:\Users\Work>node D:\nodejs\sqlwrite.js

module.js:340
    throw err;
          ^
Error: Cannot find module 'mysql'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at Object.<anonymous> (D:\nodejs\sqlwrite.js:1:74)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.runMain (module.js:492:10)

C:\Users\Work>

i have entered the commands as shown on github.

3
  • You should add path to system variable. i.e; path where you installed mysql mudule. Commented Jul 23, 2012 at 11:13
  • Which OS you are using ? Commented Jul 23, 2012 at 11:14
  • Windows 7(64bit)-Ultimate. the mysql module is not getting added in node_module folder. Commented Jul 23, 2012 at 11:16

1 Answer 1

2

You should add the path (where node modules are installed) to system variable. Or navigate to default system path for NodeJS modules and install NodeJS modules. This is path for my system:

C:\Users\[user-name]\AppData\Roaming\npm\node_modules

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

4 Comments

I copied the module from 'C:\Users\Work\node_modules\mysql' where it got installed to the nodejs folder in 'C:\Program Files (x86)\nodejs\node_modules'. Still same error.
See if that path is included in system variable Path ?
>C:\Program Files (x86)\nodejs\ is included in system variable Path.
Thankyou i needed to run the node.js command prompt as administrator,that solved the problem

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.