Node-webkit:ReferenceError:_没有定义

当我尝试使用node-webkit运行我的应用程序时,出现错误:Node-webkit:ReferenceError:_未定义。 我认为这是关于破折号,但在浏览器上一切工作正常。 这是我的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。

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

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

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

这是Lo-dash的问题。 目前的边缘版本似乎有一个修复,看到这个线程

一个快速的解决scheme似乎是用<script>require('lodash')</script>replace<script src="path_to_lodash.js"></script> <script>require('lodash')</script>