I am a complete Node.js newbie and struggling with the basics. Running this code on the server:
var http = require("http"),
sys = require("util"),
io = require("socket.io"),
GlobTrie = require("glob-trie.js");
Gives me an exception at the first require:
Uncaught ReferenceError: require is not defined
(anonymous function)
Any thoughts?
Best regards, Ben.
alessioalex
Node.js is run on the server side, not on the browser side.
Check out more about Node here: What is Node.js?
Ben
Case closed, I was including the wrong file on the client!
Sorry to waste people time, but thanks for the Node links.
来源:https://stackoverflow.com/questions/8404562/node-js-require-is-not-defined-exception