Uncaught ReferenceError: _ is not defined

Avatar

Avatar
Level 1
sravs
Level 1

Likes

0 likes

Total Posts

7 posts

Correct reply

0 solutions
View profile

Avatar
Level 1
sravs
Level 1

Likes

0 likes

Total Posts

7 posts

Correct reply

0 solutions
View profile
sravs
Level 1

26-03-2021

while I'm trying to use a custom clientlib its throwing the error as Uncaught ReferenceError: _ is not defined I added dependency as lodash also.

can you please help me in this

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
Level 6
Bhuwan_B
Level 6

Likes

133 likes

Total Posts

127 posts

Correct reply

50 solutions
Top badges earned
Validate 1
Affirm 50
Give Back 5
Boost 100
Give Back 3
View profile

Avatar
Validate 1
Level 6
Bhuwan_B
Level 6

Likes

133 likes

Total Posts

127 posts

Correct reply

50 solutions
Top badges earned
Validate 1
Affirm 50
Give Back 5
Boost 100
Give Back 3
View profile
Bhuwan_B
Level 6

27-03-2021

Usually this error comes if your code has dependency on Underscore.js/LoDash.js . Can you please try validating if its added and loading properly. https://stackoverflow.com/questions/13556010/referenceerror-is-not-defined

Answers (3)

Answers (3)

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,444 likes

Total Posts

3,322 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,444 likes

Total Posts

3,322 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

28-03-2021

please check sample code here if you are using color picker 

https://aemlab.blogspot.com/2019/07/aem-rte-custom-plugins-1.html

Avatar

Avatar
Applaud 25
Level 10
asutosh_jena
Level 10

Likes

593 likes

Total Posts

705 posts

Correct reply

207 solutions
Top badges earned
Applaud 25
Give Back 100
Boost 500
Affirm 100
Ignite 1
View profile

Avatar
Applaud 25
Level 10
asutosh_jena
Level 10

Likes

593 likes

Total Posts

705 posts

Correct reply

207 solutions
Top badges earned
Applaud 25
Give Back 100
Boost 500
Affirm 100
Ignite 1
View profile
asutosh_jena
Level 10

26-03-2021

Hi @sravs 

Please add 'cq.jquery' as dependency and see if it resolves the issue.

 

Thanks!

Avatar

Avatar
Level 1
gilbertcane
Level 1

Likes

0 likes

Total Posts

1 post

Correct reply

0 solutions
View profile

Avatar
Level 1
gilbertcane
Level 1

Likes

0 likes

Total Posts

1 post

Correct reply

0 solutions
View profile
gilbertcane
Level 1

29-06-2021

If you are using any script file and getting "Uncaught ReferenceError: x is not defined " which means 'x' is either a variable or a method which you are trying to use before declaring it using var keyword. This means that there is a non-existent variable referenced somewhere. This variable needs to be declared, or you need to make sure it is available in your current script or scope otherwise , it will endup throwing this 'x' is not defined error . This usually indicates that your library is not loaded and JavaScript does not recognize the 'x'.

 

To solve this error: Load your library at the beginning of all your scripts.

 

There can be multiple other reasons for this issue:

 

  • Conflict with Other Libraries
  • Path to your library included is not correct
  • Llibrary file is corrupted
  • Working offline (when you use CDN)