I want to import jQuery in an Angular 5 project using TypeScript 2.8.1. I follow Ervin Llojku solution but this does not the trick :
Install jquery with npm
npm install --save jqueryInstall jquery with npm
npm install --save-dev @types/jqueryAdd scripts to .angular-cli.json
"apps": [{ ... "scripts": [ "../node_modules/jquery/dist/jquery.min.js", ], ... }]
I also try to add these imports in app.module.ts or in component :
import * as $ 'jquery';
Whatever I try TypeScript compiler throws this error :
Error:(7, 15) TS2497: Module ''jquery'' resolves to a non-module entity and cannot be imported using this construct.
I have followed another answer and I replaced
with
in app.module.ts and everything seems to be OK.
Still I don't know if this error was due to Angular 5 or TypeScript 2.8.1...
or maybe to the tsconfig.json generated by Angular :