Search code examples
node.jsnode.js-connect

How do I manually install node.js connect on Windows?


I have tried installing connect via npm install connect, and according to npm, the installation works fine.

However, once I try running a program that requires connect, I get the following message:

>node server.js

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: Cannot find module 'connect'
    at Function._resolveFilename (module.js:332:11)
    at Function._load (module.js:279:25)
    at Module.require (module.js:354:17)
    at require (module.js:370:17)
    at Object.<anonymous> (C:\Users\lowerkey\Desktop\emasc\server\server.js:2:15
)
    at Module._compile (module.js:441:26)
    at Object..js (module.js:459:10)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)
    at Array.0 (module.js:479:10)

So my question is this: How do I install connect manually? I have cloned the github repository, but now I'm stuck.


Solution

  • What is in the node modules_directory in your project?

    Remember NPM doesn't install the modules globally by default, if you run npm install connect you need to be in your projects root directory.

    If NPM has failed you simply create a node_modules directory in your project root and move the cloned repository there.

    You can also put it elsewhere within your project and require it with an explicit path so if you put it into ./modules/connect then you will need to require('./modules/connect') in your js file.