Xoaks
Xoaks

Reputation: 53

Cannot read property of 'fn' of undefined?

Getting these error codes on my github pages. I have these as my order of loading scripts:

<script src="../../node_modules/jquery/dist/jquery.js"></script>
<script src="../../js/bootstrap.min.js"></script>
<script src="../../js/index.js"></script>

Here are the error messages:

GET https://tmolano.github.io/CareerMod4/node_modules/jquery/dist/jquery.js 404 ()
index.html:115 GET https://tmolano.github.io/CareerMod4/node_modules/popper.js/dist/popper.min.js 404 ()
util.js:56 Uncaught TypeError: Cannot read property 'fn' of undefined
    at util.js:56
    at util.js:10
    at bootstrap.min.js:6
    at bootstrap.min.js:6
(anonymous) @ util.js:56
(anonymous) @ util.js:10
(anonymous) @ bootstrap.min.js:6
(anonymous) @ bootstrap.min.js:6

Heres my page: https://tmolano.github.io/CareerMod4/

Other than the order of loading, what else could be causing this?

Upvotes: 1

Views: 12603

Answers (2)

Trinh Hieu
Trinh Hieu

Reputation: 805

Update 2023:

I used this code snippet to fix all the problems I had!

As of bootstrap 5 they will require you to use their Proper . And here I use Bundle and it still works well with all functions

for nextjs 13

  <Script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js" />
  <Script type="text/javascript" src="https://unpkg.com/@popperjs/core@2" />
  <Script
    type="text/javascript"
    src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
    integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
    crossOrigin="anonymous"
  />

Upvotes: 0

Ali Sheikhpour
Ali Sheikhpour

Reputation: 11096

Possible reasons for this error:

Uncaught TypeError: Cannot read property 'fn' of undefined

  1. invalid reference to the file addresses or missing files (Your case).
  2. Duplicate reference to the Jquery.
  3. Overriding $ sign of Jquery in 3rd party libraries.
  4. Using Jquery functions before inserting Jquery (Not your case).
  5. Using deprecated syntax for load,error,unload on WINDOW element in jquery without on

Upvotes: 6

Related Questions