$ being flagged as not defined in js file when using jQuery




Not exactly sure when but at some point recently Cloud9 started flagging up the $ symbol as not defined in any of my files. I am using jQuery and my code functions correctly.

Its not a big deal but I just wondered if I’d done something to cause this?




I’m assuming that you’re using jQuery by including it via a script tag within your html file. If so, the linter doesn’t know where the $ is coming from, and thus lets you know about this. If your code is working fine, you can ignore this.

If you’d like to prevent such errors, you can create an .eslintrc file in the workspace folder and set it up as follows:

  "env": {
    "browser": 1
  "globals": {
    "angular": 1

Hope this helps.



Thanks for that. Yeah I can ignore it but on a JS file where I’m using predominantly jQuery, it’s nearly every line being flagged :unamused:


Hi @MDillenger,

just to make it clear: you didn’t do anything wrong. The warning is issued by a little code checking tool (a Lint tool). It simply wants to tell you that you’re using a variable $ without defining it. It doesn’t know that you’re importing jQuery elsewhere. Here’s a similar thread with more information.

In order to fix it for all files in your workspace, consider the solution from @mutahhir. c9.io is using a lint tool called ESLint. If you’re using global variables in many files, just add a .eslintrc and tell ESLint which variable names are available across all your files.

Check out ESLint’s documentation if you want to make further adjustments (it’s super flexible and powerful).



Hey guys,

I just had this problem too and there is a much easier solution than creating a separate ESLint file.

Just add this to the top of your script:

/* global $ */

Hope that helps.


Hey @adammarcwilliams,
This was much simple. Great! it worked.



where to add the comment in HTML file or in jquery.min.js file.


Put it wherever your JavaScript is. If you’re using a <script></script> in an HTML file, put it first thing inside the script tag, if you have a separate file with your JavaScript, put it there.


hey! Im having similar error:
says: ReferenceError: $ is not defined

in my js file… i added /* global $ */ to the top of the script but doesnt help… any suggestions?