1

I have installed some modules via npm install <module> and I can access them when I run node at the command prompt, but when I run the app under IIS using iisnode, I get errors like:

Application has thrown an uncaught exception and is terminated:
Error: Cannot find module 'formidable'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (C:\Program Files\iisnode\www\helloworld\hello.js:3:18)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

What is going on? Is there a different way I have to install modules if I am using iisnode?

Here is my web.config file from the project:

<configuration>
  <system.webServer>

    <!-- indicates that the hello.js file is a node.js application 
to be handled by the iisnode module -->

    <handlers>
      <add name="iisnode" path="hello.js" verb="*" modules="iisnode" />
    </handlers>

  </system.webServer>
</configuration> 
2
  • it should work. Please show more code & config. Commented Apr 14, 2014 at 8:31
  • OK, I added my web.config file. I'm not sure what else to add, everything else is the same as the defaults. Commented Apr 14, 2014 at 15:57

2 Answers 2

1

Since npm 1.0, there are two ways to install things: Globally & Locally. Read documentation here.

Global install (with -g) for something you want to use in your shell or on the command line.

When you install a package locally, via npm install onepackage, it will insert the dependency into package.json and add the library under the directory node_modules. This is mainly for a package you want to use in your program, using require('onepackage').

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

Comments

0

Looks like I found the problem. Unlike most package managers I've used, npm does not install things globally, but only to the folder you are located in when you install. I installed in the correct folder and it seems to be working.

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.