Node.js - 需要未定义异常

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8404562/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 14:52:10  来源:igfitidea点击:

Node.js - require is not defined exception

node.jsrequire

提问by Ben

I am a complete Node.js newbie and struggling with the basics. Running this code on the server:

我是一个完整的 Node.js 新手并且正在努力学习基础知识。在服务器上运行此代码:

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.

最好的问候,本。

采纳答案by Ben

Case closed, I was including the wrong file on the client!

案例关闭,我在客户端上包含了错误的文件!

Sorry to waste people time, but thanks for the Node links.

很抱歉浪费人们的时间,但感谢节点链接。

回答by alessioalex

Node.js is run on the server side, not on the browser side.

Node.js 运行在服务器端,而不是浏览器端。

Check out more about Node here: What is Node.js?

在此处查看有关 Node 的更多信息:什么是 Node.js?