Node.js 节点在IIS中找不到模块,可以从提示符中查找

Node.js 节点在IIS中找不到模块,可以从提示符中查找,node.js,iis,module,npm,iisnode,Node.js,Iis,Module,Npm,Iisnode,我已经通过npm install安装了一些模块,当我在命令提示下运行node时可以访问它们,但当我使用iisnode在IIS下运行应用程序时,会出现如下错误: Application has thrown an uncaught exception and is terminated: Error: Cannot find module 'formidable' at Function.Module._resolveFilename (module.js:338:15) at F

我已经通过
npm install
安装了一些模块,当我在命令提示下运行
node
时可以访问它们,但当我使用
iisnode
在IIS下运行应用程序时,会出现如下错误:

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)

看来我找到问题了。与我使用过的大多数软件包管理器不同,
npm
不会全局安装,而只在安装时安装到您所在的文件夹中。我安装在正确的文件夹中,它似乎正在工作。

自npm 1.0以来,有两种安装方式:全局和本地。阅读文档

全局安装(使用
-g
)以在shell或命令行中使用


当您通过
npm install onepackage
在本地安装软件包时,它会将依赖项插入package.json,并将库添加到
节点模块
目录下。这主要针对您希望在程序中使用的包,使用
require('onepackage')

它应该可以工作。请显示更多代码&config.OK,我添加了我的
web.config
文件。我不确定还要添加什么,其他所有内容都与默认值相同。
<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>