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