错误:找不到模块“连接” [英] Error: Cannot find module 'connect'

查看:96
本文介绍了错误:找不到模块“连接”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我将其安装到文件目录中后,似乎这个简单的应用程序找不到‘connect’模块。

It appears that this simple app can't find the 'connect' module after I just installed it in the file directory.

var connect = require ('connect');

connect.createServer(function(res, req, next) {
    res.simpleBody("Connect you son of a beeeeetch");

}).listen(8000);



express@3.1.0 node_modules/express
├── methods@0.0.1
├── fresh@0.1.0
├── range-parser@0.0.4
├── cookie-signature@0.0.1
├── buffer-crc32@0.1.1
├── cookie@0.0.5
├── debug@0.7.2
├── commander@0.6.1
├── mkdirp@0.3.3
├── send@0.1.0 (mime@1.2.6)
└── connect@2.7.2 (pause@0.0.1, bytes@0.1.0, formidable@1.0.11, qs@0.5.1)
Dzs-Mac-Attax-2:PlsWrk Dz$ node test.js

module.js:340
    throw err;
      ^
Error: Cannot find module 'connect'
    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> (/Users/Dz/Documents/NodeTests/PlsWrk/test.js:1:77)
    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)


推荐答案

快递内部使用 Connect 作为其node_modules依赖项之一。

Express internally uses Connect as one of its node_modules dependencies.

如果您希望在应用程序中使用Connect,则需要将其添加到 package.json 并运行 npm update

If you wish to use Connect in your app, you'll need to add it to your package.json and run npm update.

根据设计,每个节点模块都有自己的内部私有依赖项。

By design, each node module has its own private internal dependencies.

如果要使用任何依赖项,您的应用程序也需要安装它们。

If you want to use any, your app will need to install them too.

这意味着您的应用可以使用不同版本的模块,并且每个模块可以在内部使用不同的版本再次没有冲突。

It means your app can use a different version of the modules, and each module can internally use different versions again without conflicts.

这篇关于错误:找不到模块“连接”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆