Reputation: 315
When I try to run my app with node-webkit I have error: Node-webkit: ReferenceError: _ is not defined. I think it is about Lo-dash, but on browser everything work fine. Here is my index.html code:
<!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>
In components.min.js i have all components I need - lodash, angular etc. When I run it by browsers or appJS i haven't any error, only on node-webkit.
Upvotes: 1
Views: 2579
Reputation: 121
This is an issue with Lo-dash. The current edge version seems to have a fix for it, see this thread
A quick solutions seems to be to replace <script src="path_to_lodash.js"></script>
with <script>require('lodash')</script>
Upvotes: 1
Reputation: 464
Quite usually these reference errors arise when some script tries to reference another script which isn't loaded yet. Basically, the order in which you register your script matters. Script that is referenced should be registered before the script that uses it.
A good explanation of this issue (although with JQuery's $ selectors instead of the lodash _), is in this article here: http://jquery-howto.blogspot.nl/2013/02/referenceerror-jquery-is-not-defined.html.
Thus I would check the order in which your .js files are registered and their dependencies.
Upvotes: 1