Reputation: 132
I have a problem using jQuery in my project (with Angular and boosted which is a fork of bootstrap). The error is below:
ERROR in folder/containing/my/component.ts: error TS2581: Cannot find name '$'. Do you need to install type definitions for jQuery? Try
npm i @types/jquery
.
I have installed @types/jquery
and jquery
, and I have added the script in angular.json file:
"dependencies": {
// ...
"boosted": "^4.3.1",
"bootstrap": "^4.4.1",
},
"devDependencies": {
// ...
"typescript": "~3.1.6"
}
"scripts":[
// ...
"node_modules/@types/jquery/dist/jquery.slim.d.ts",
"node_modules/jquery/dist/jquery.js"
]
Upvotes: 2
Views: 3669
Reputation: 1601
Try to install jquery.
npm install jquery
And then import jquery as $. like below
import * as $ from 'jquery';
Upvotes: 4