Intellisense doesn't work for JavaScript in Visual Studio 2012
Solution 1
Kudos to CraigTP
Summary:
navigate to the [Tools] > [Options] > Text Editor > JavaScript > IntelliSense > References options
-
select Implicit (Web)
you can find "~/Scripts/_references.js" (if you want to put it in different place, change it here)
go to ~/Scripts and add new item "_references.js"
-
add
/// <reference path="path\jquery-1.7.1.js" />
in "_references.js"or
/// <reference path="~\root\path\jquery-1.7.1.js" />
Happy coding :)
Edit note:
Remember to put jquery-1.7.1-vsdoc.js in the same folder with jquery-1.7.1.js
After making above mentioned changes, if it is still not working try restarting visual studio.
Solution 2
Go to menu Tools -> Options -> Text Editor -> JavaScript -> Intellisense -> References and place a reference to the intellisense files for the version of jQuery you are using in the Implicit Web group.
OR
place an "add reference" to the intellisense file in the _references.js file which you can add to the Scripts
folder of your project.
/// <reference path="jquery-1.8.2.js"/>
/// <reference path="jquery-1.8.2.min.js"/>
/// <reference path="jquery-1.8.2.intellisense.js"/>
Though this will only provide intellisense for the project you are in, the first will for any open JavaScript file, not just the ones in the project you are in.
To get the latest jQuery files with intellisense use the NuGet package installer which by default will create a scripts folder and place the jQuery version.js, the min.js and intellisense.js files into... From there you can copy them to the location most of the Microsoft references are placed in, which is typically:
install-package jquery
in the package manager console.
C:\Program Files (x86)\Microsoft Visual Studio 11.0\JavaScript\References
Solution 3
Summary:
- Drag the
.js
file you want to reference from Solution Explorer into your current one. (Visual studio will create a reference snippet.)
Solution 4
Try adding them to your implicit JavaScript references. This is located at Tools -> Options -> Text Editor -> JavaScript -> IntelliSense -> References.
Solution 5
To add jQuery and its intellisense files to an active/opened project/website
In Visual Studio 2012, do the following:
Open menu Tools -> Library Packet Manager -> Manage Nuget packages for solution. Click the Online field/selector in the very right side of the dialog box. Find jQuery in the middle list, click it, and click Install.
Observe that the jQuery script files are now inserted into your project by looking at the Solution Explorer panel. You should see jquery-1.x.x.js (where x here is are placeholders for the actual version numbers. Say jquery-1.9.0.js is a concrete example).
Also, observe that there is now a Jquery-1.9.0.intellisense.js file there. Neat ai? :-)
But bear in mind, that if you create a new website in Visual Studio and choose ASP:NET Web forms site (as opposed to an Empty site) the web forms site will already have jQuery 1.7.1 in there).
Konrad Viltersten
A self taught code monkey since the age of 10 when I got my first computer, the coolest Atari 65XE. Later on, a mathematics and computer science student at a university with a lot of side-studies in philosophy, history, Japanese etc. Today, a passionate developer with focus on web related technology from UX, through JS/TS to C# with a touch of SQL. Motto: A lousy programmer knows how to create problems. A good programmer knows how to solve problems. A great programmer knows how to avoid them. (Get the double meaning?) Works at: http://kentor.se Blogs at: http://konradviltersten.wordpress.com Lives at: http://viltersten.somee.com
Updated on July 09, 2022Comments
-
Konrad Viltersten almost 2 years
I have a clean, out-of-the-box installation of Visual Studio 2012 Web Developer Express and for some reason the support for JavaScript (both jQuery, jQuery UI and other libraries) has disappeared. I believe it worked before and then for "no reason" it stopped.
I've browsed the web as supposed to and discovered four discrepancies.
I don't have the key HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\JavaScriptLanguageService\ImplicitReferences in my registry. In fact, I don't even have JavaScriptLanguageService directory.
I've checked that the referred file domWindows.js indeed is where the options point to.
The output window under JavaScriptLanguageService is empty and nothing is being typed there while I develop and run my application.
I've referred to the jQuery-file that I'm using through the options but it didn't produce any changes.
All in all I get the error message saying that:
"intellisense was unable to determine an accurate completion list for this expression, The provided list contains all identifiers in the file"
Any suggestions would be warmly appreciated.
-
Konrad Viltersten almost 12 yearsWhat exactly is supposed to be there? I have the following references right now: libhelp.js sitetypesWeb.js domWeb.js underscorefilter.js showPlainComments.js (all the above at paths on form c:\something) Besides that i have: ~/Scripts/_references.js (however, thre's no such file in my projects directory - could that be an issue?)
-
Konrad Viltersten almost 12 yearsNow, i'm a bit unclear on WHICH file to reference for intellisense. Should i go for the actual jQuery-1.7.2.js itself (in my project directory) or should i reference \Microsoft Visual Studio 11.0\JavaScript\References\jquery.intellisense.js?! It might be the sleep deprivation talking but i don't recall putting that file into the directory... Is it there by default?
-
alexdd55 almost 12 yearswhen i open up this jquery.intellisense.js al there is to find is one simple function and a kind of signature. after adding this file nothing changed in the IDE itself.. kind of sad...
-
Konrad Viltersten almost 12 yearsIt's a neat solution (I haven't tried it yet but i can appreciate the neatness, anyway, haha). Now, all that will work until i upgrade to a newer version of jQ, which will be released shortly. Of course, editing the path to 1.8 is not a big deal but it'd be ever more neat if that would be done automagically, wouldn't it? I can't think of any way to achieve that (other than starting to work for MS and coding in the updator into VS myself - but is not very likely to happen).
-
maxisam almost 12 yearsIf you use nuget to upgrade your jQ. Nuget will change it to 1.8 automatically. However, there is no vsdoc.js for 1.8. So you will lose the intellisense support. In the end, you actually wish Nuget doesn't upgrade that automatically. And thanks for marking this as answer
-
Konrad Viltersten almost 12 yearsI'm sure that vsdoc.js for 1.8 will be available shortly. And in the meantime, maybe one can rename docs of 1.7 to 1.8 and cheat. Of course, that defeats the very purpose of automatic update. By the way, I've never used NuGet. Did I miss much?
-
maxisam almost 12 yearsnuget.org Not so much. Just about 2 years lol. You really need to try it. It is a must-have plugin for VS.
-
Konrad Viltersten almost 12 yearsHaha, I think I'll wait until docs for 1.8 arrive. I wouldn't like to try out this must-have plug-in when it doesn't work. Intellisense is more must-have to me than NuGet. :)
-
maxisam almost 12 yearsYou should read this from Nuget first. "NuGet is a Visual Studio extension that makes it easy to install and update third-party libraries and tools in Visual Studio"
-
Mike K about 10 yearsI've tried every single thing on this page and nothing works. Using VS2013.
-
rupps about 8 yearsGive a try to IntelliJ WebStorm. It's lightyears ahead of VS when it comes to intellisense, and it's integrated with JSLint, Google Closure Compiler, JSDoc and many other standards.
-
TheCrazyProgrammer about 7 yearsIf NuGet errors out with message that default project not found, it means the project you open (e.g. Node.js) is not supported by NuGet. In that case you need to use other methods as already explained in the answer.