0
我最近在一个新的Linode盒子上安装了Node.js,我想我处于一个奇怪的情况,我不能使用require()
加载任何第三方模块。如何使用Node.js模块?
我已经安装npm
并通过npm
已成功安装模块,但每当我试图模块require
一个(或只在同一目录下的一些我自己的代码),Node.js的throws
的error
说它找不到该模块。
有关为什么会发生这种情况的任何想法?
下面是一个例子错误消息:
[email protected]:/home/mike# npm install sequelize
npm ERR! sudon't!
npm ERR! sudon't! Running npm as root is not recommended!
npm ERR! sudon't! Seriously, don't do this!
npm ERR! sudon't!
npm info it worked if it ends with ok
npm info version 0.2.2
npm info fetch http://registry.npmjs.org/sequelize/-/[email protected]
npm info install [email protected]
npm info activate [email protected]
npm info build Success: [email protected]
npm ok
[email protected]:/home/mike# node
> var n = require('sequelize').Sequelize
Error: No such native module sequelize
at requireNative (node.js:83:32)
at cwdRequire (repl:27:10)
at [object Context]:1:9
at Interface.<anonymous> (repl:96:19)
at Interface.emit (events:27:15)
at Interface._ttyWrite (readline:295:12)
at Interface.write (readline:132:30)
at Stream.<anonymous> (repl:77:9)
at Stream.emit (events:27:15)
at IOWatcher.callback (net:489:16)
可以确认。您不能在最新版本的Node.JS中从命令行“需要”一个模块。悲伤但真实。 – Andris 2010-09-29 19:18:21
很高兴知道,感谢您的帮助。 – Mike 2010-10-01 05:05:09