In this SPFx tutorial, we will discuss how to fix error, “cannot find module jquery spfx“.
Recently while developing a SharePoint framework crud operations with no javascript framework, I got the error while I tried to run the below command:
gulp serve
The error comes as:
error TS2307: Cannot find module ‘jquery’ and the error looks like below:

The same error sometimes, you will get after adding the web part to a modern SharePoint page like below:
[SPLoaderError.loadComponentError]: Failed to load component “”. Original error. Failed to load entry point from component. Error loading… Cannot find module ‘jquery’

cannot find module jquery spfx
The error will comes if jQuery is not installed in SPFx solutions. Run the below command to install jQuery in the SPFx solution.
npm install jquery --save

If the solution did not work, then you can try to install the exact version of jQuery by running the below command:
npm uninstall @types/jquery
npm install @types/jquery@3.5.1 --save
Also, you can refer the jQuery from the CDN. Open the config/config.json file and then add the below code:
"externals":{
"jquery": "https://code.jquery.com/jquery-3.1.0.min.js"
},
Ideally, if you want to use jQuery in SPFx web parts, then you should install the type declarations for jQuery.
npm install --save-dev @types/jquery
You may like the following SPFx tutorials:
- How to Set up SharePoint Framework development environment
- (SPFx) SharePoint framework client web part example
- SharePoint Framework (SPFx) Extensions Application Customizer Example
- Create and Deploy SharePoint Framework (SPFx) extension field customizer
- Create and deploy SharePoint Framework (SPFx) listview command set extension
I hop this tutorial helps to fix error, cannot find module jquery spfx.
I am Bijay a Microsoft MVP (8 times –Â My MVP Profile) in SharePoint and have more than 15 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com