krasimir/navigo

Uncaught ReferenceError: Navigo is not defined

JulioFS opened this issue · 2 comments

Cheers,

Using 8.11.0 (but having the issue happening with all the 8+ versions), I see this in the console:

Uncaught ReferenceError: Navigo is not defined

Markup is a simple HTML and JS combo, where router is defined, the error happen as soon as I try to define Navigo inside a <script> tag in the markup:

const router = new Navigo('/frontend');

Navigo JS is actually loaded correctly, I see it in the console loaded, however "Navigo" itself is not available in the global Namespace.

However, exports.Navigo is available, so issuing const router = new exports.Navigo('/frontend'); works fine.

This on Chrome 89.0.4389.90 (Official Build) (64-bit), Linux (Pop OS 20.10).

I am using VSCodium 1.54.3 with the "Live Server" Extension (5.6.1), version 7.x, which is what I was using before works just fine.

I noticed that in the JS bootstrap the following:

"function" == typeof define && define.amd ? define("Navigo", [], n) : "object" == typeof exports ? exports.Navigo = n() : t.Navigo = n()

There is no "define" function (reqirejs holdover?), but there is however, an "exports" object, so it seems like the Navigo NS is placed in this object.

Any insights on this issue will be appreciated, TIA.

--SB

Hey,

my question will be ... if you are injecting Navigo with a <script> tag then where's this exports coming from?

Thanks for the reply,

Indeed exports was a holdover empty object definition intended to debug a popper issue on bootstrap 4, I feel embarrased! :)

Thanks for pointing up the obvious, I removed the early definition of exports in the code and all works as it should now.