Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Uncaught ReferenceError: _ is not defined

sravs
Level 1
Level 1

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

1 Accepted Solution
Bhuwan_B
Correct answer by
Community Advisor
Community Advisor
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

View solution in original post

11 Replies
asutosh_jena
Community Advisor
Community Advisor

Hi @sravs 

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

 

Thanks!

asutosh_jena
Community Advisor
Community Advisor
What type of custom clientlib it is? Is it reproducible on we-retail as well?
sravs
Level 1
Level 1
Yeah, I'm using AEM 6.5.3 I tried to add a colorpicker plugin for RTE
asutosh_jena
Community Advisor
Community Advisor

@sravs If this is still not resolved, please share the code package to debug further.

Bhuwan_B
Correct answer by
Community Advisor
Community Advisor
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

View solution in original post

gilbertcane
Level 1
Level 1

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)