The “Cannot Find Name ‘jQuery'” error in TypeScript often occurs when we forget to install jQuery or its typings in our project. Please follow our tutorial below to find out some of the ways to solve this.
What causes the “Cannot Find Name ‘jQuery'” error?
jQuery is a JavaScript library that aims to make JavaScript code more straightforward to read. Its influence on JavaScript is so huge that some claim it has changed how many developers write JavaScript code.
Since TypeScript is a superset of JavaScript, you can use jQuery in TypeScript as you would in JavaScript. However, you can sometimes run into these errors:
Cannot find name 'jQuery'
or
Cannot find name '$'
Most of the time, you get this error because you have not installed jQuery or its typings, or installed the wrong version of @types/jquery
.
How to fix this problem
Solution 1: Install the @types package
To start using jQuery for TypeScript, we have to install it firstly. Go into the root folder of your project and open the terminal. Then, type in:
npm install jquery
Find the folder of your ‘package.json’ file. Open the terminal in the same folder, then type in:
npm install --save-dev @types/jquery
You will get something like this:
npm WARN code No description
npm WARN code No repository field.
npm WARN code No license field.
+ @typs/[email protected]
added 2 packages from 22 contributors and audited 73 packages in 3.124s
8 packages are looking for funding
run `npm fund` for details
Found 0 vulnerabilities
Solution 2: Install the package manually
If for some reason, you cannot install the package with the first method, you can try to download it manually via this link.
However, this method is not really recommended.
After setting everything up successfully, you can now import the jQuery library to use as normal:
import $ from "jquery";
or
import $ = require("jquery");
If the error still happens, you can try to rerun the installation and restart your IDE.
Summary
The “Cannot Find Name ‘jQuery’” error in TypeScript is a common error. It often occurs when we forget to install the jQuery library or its type before using it. The solution is to install the library and its typings using the two methods we have shown above.
Maybe you are interested:
- Cannot find name ‘require’ error in typescript
- Cannot invoke an object which is possibly ‘undefined’ in TS
- Cannot redeclare block-scoped variable in TypeScript

Hello. My name is Khanh Hai Ngo. I graduated in Information Technology at VinUni. My advanced programming languages include C, C++, Python, Java, JavaScript, TypeScript, and R, which I would like to share with you. You will benefit from my content.
Name of the university: VinUni
Major: EE
Programming Languages: C, C++, Python, Java, JavaScript, TypeScript, R