Node-webkit:ReferenceError:_未定义

时间:2014-09-23 07:13:44

标签: javascript node.js webkit node-webkit

当我尝试使用node-webkit运行我的应用程序时出现错误:Node-webkit:ReferenceError:_未定义。我认为这是关于Lo-dash,但在浏览器上一切正常。这是我的index.html代码:

<!DOCTYPE html>
<html ng-app="viewer">
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="style.css">
    <link rel="stylesheet" href="css/font-awesome.css">
    <script src="components.min.js"></script>
    <script src="app.min.js"></script>
</head>
<body>
<div id="content"></div>
<div ui-view></div>
</body>
</html>

在components.min.js我有我需要的所有组件 - lodash,angular等。当我通过浏览器或appJS运行时我没有任何错误,只在node-webkit上。

2 个答案:

答案 0 :(得分:1)

通常,当某些脚本尝试引用尚未加载的另一个脚本时,会出现这些引用错误。基本上,您注册脚本的顺序很重要。引用的脚本应在使用它的脚本之前注册。

这个问题的一个很好的解释(虽然使用JQuery的$ selectors而不是lodash _),这篇文章在这里:http://jquery-howto.blogspot.nl/2013/02/referenceerror-jquery-is-not-defined.html

因此,我会检查.js文件的注册顺序及其依赖关系。

答案 1 :(得分:1)

这是Lo-dash的问题。目前的边缘版本似乎有一个修复,请参阅this thread

快速解决方案似乎是将<script src="path_to_lodash.js"></script>替换为<script>require('lodash')</script>