Error while including a third party JS module in my plugin
-
My plugin.json
"modules": { "geocomplete.js": "static/lib/geocomplete/jquery.geocomplete.min.js", "tree.js": "static/lib/jstree/jstree.min.js" },
In my map.js file
requirejs(["tree"], function(tree) { ... }
When I run, the browser raises this error:
Uncaught TypeError: Cannot read property 'jstree' of undefined at tree.js?v=pl4hsgl3sro:2 at Object.execCb (require.js:29) at w.check (require.js:18) at w.<anonymous> (require.js:22) at require.js:7 at require.js:23 at y (require.js:6) at w.emit (require.js:23) at w.check (require.js:19) at w.enable (require.js:23)
When I hover over the second line i.e. at tree.js?v=pl4hsgl3sro:2
it displays this path: localhost:4567/src/modules/tree.js?v=pl4hsgl3sro:2When I click on it it displays the contents (minified code) of the tree.min.js in the Sources heading.
What shall I do, kindly help me resolve this error.
-
I suggest changing it to use the unminified files, this way you get the actual code in development. NodeBB automatically minifies all of those files in a production environment anyways. I also suggest you change it to use the same filename as the original:
jstree.js
instead oftree.js
.Then you should be able to debug a little easier.
-
I think I have the same issues as described in this URL:
https://groups.google.com/forum/#!topic/requirejs/wpnQEWHCPDgBut there is no definitive answer over there.
-