I have an Angular 13 project where we use jquery. We use jquery because we are importing another project that is coded using jquery.
So, I ran npm install jquery
, and got this in my package.json
file: "jquery": "^3.5.1"
.
I checked the node_modules
folder as well, and found that jquery has been downloaded.
Then I run ng serve
.
Then I open Chrome and go to the localhost
URL to access the application. I open Dev tools within Chrome, go into the command line, and type $().jquery
to verify that jquery has been installed. When I do that, I get this error:
Uncaught TypeError: Cannot read properties of undefined (reading 'jquery') at <anonymous>:1:4
So, jquery has not been installed.
Any suggestions on how to install jquery with npm install
in an Angular application?
UPDATE: When I added node_modules/jquery/dist/jquery.min.js
to the "scripts" element in angular.json
, the command $().jquery
worked in the Dev console terminal and I was able to see the version number of jquery.