0

I recently installed Node.js on a fresh Linode box, and I think I'm in a weird situation where I can't use require() to load any third party modules.

I've installed npm and have successfully installed modules via npm, but whenever I try to require one of the modules (or just some of my own code in the same directory), Node.js throws an error saying it can't find the module.

Any thoughts as to why this might be happening?

Here's an example error message:

root@li200-141:/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 root@li200-141:/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) 

1 Answer 1

2

Apparently, there is a bug in node v0.2.2 that prevents require from working properly from the REPL.

Try putting your code in a .js file instead. That worked for me.

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

1 Comment

Can confirm. You can't require a module from the command line in the latest version of Node.JS. Sad but true.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.