【发布时间】:2014-07-26 21:58:18
【问题描述】:
我最近开始玩 node-webkit 并尝试创建一个简单的 HelloWorld + 加载一个模块。 我选择测试的模块是“getmac”(https://www.npmjs.org/package/getmac)。
这是我的代码:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
var gm = require('getmac');
</script>
<title>Hello World!</title>
</head>
<body>
<h1>Hi!</h1>
We are using node.js <script>document.write(process.version)</script>.
</body>
</html>
我通常使用 npm install 安装模块,并且我的 app 文件夹中有一个 node_modules 文件夹。我所有的资源都在文件夹内(没有其他文件夹,除了 node_modules -> 这意味着没有树结构)。
当我运行此代码时,我收到“找不到模块”错误。我还阅读了有关使用 nw-gyp 重新构建模块的内容,但我什至不知道在这种情况下是否有必要(如果可能,请在答案中包含有关此内容的内容)。
无论如何,感谢所有帮助。
注意:helloworld 可以在不尝试加载模块的情况下工作。
【问题讨论】:
标签: node.js node-webkit