Could not find a declaration file for module 'jquery' #239

Closed
opened 2025-08-09 17:15:32 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @mikewalkerjr on 1/8/2018

I'm attempting to use jQuery within my project.

Within the package.json file, it has

  "devDependencies": {
    "@types/webpack-env": "^1.13.0",
    "aspnet-webpack": "^2.0.1",
    "awesome-typescript-loader": "^3.0.0",
    "bootstrap": "^3.3.6",
    "css-loader": "^0.25.0",
    "event-source-polyfill": "^0.0.7",
    "extract-text-webpack-plugin": "^2.0.0-rc",
    "file-loader": "^0.9.0",
    "isomorphic-fetch": "^2.2.1",
    "jquery": "^3.2.1",
    "style-loader": "^0.13.1",
    "typescript": "^2.2.1",
    "url-loader": "^0.5.7",
    "vue": "^2.2.2",
    "vue-loader": "^11.1.4",
    "vue-property-decorator": "^5.0.1",
    "vue-router": "^2.3.0",
    "vue-template-compiler": "^2.2.2",
    "webpack": "^2.2.0",
    "webpack-hot-middleware": "^2.12.2"
  }

And within the ProjectName.Web.csproj:

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
    <PackageReference Include="jQuery" Version="3.2.1" />
  </ItemGroup>

I installed Install jQuery and its type definitions using npm install --save jquery @types/jquery. I then attempt to import jQuery into my Typescript file using import * as $ from 'jquery'; That produces an error:

Could not find a declaration file for module 'jquery'. {project_path}/node_modules/jquery/dist/jquery.js' implicitly has an 'any' type.

What setting am I missing in order to use jQuery for this template?

*Originally created by @mikewalkerjr on 1/8/2018* I'm attempting to use `jQuery` within my project. Within the `package.json` file, it has "devDependencies": { "@types/webpack-env": "^1.13.0", "aspnet-webpack": "^2.0.1", "awesome-typescript-loader": "^3.0.0", "bootstrap": "^3.3.6", "css-loader": "^0.25.0", "event-source-polyfill": "^0.0.7", "extract-text-webpack-plugin": "^2.0.0-rc", "file-loader": "^0.9.0", "isomorphic-fetch": "^2.2.1", "jquery": "^3.2.1", "style-loader": "^0.13.1", "typescript": "^2.2.1", "url-loader": "^0.5.7", "vue": "^2.2.2", "vue-loader": "^11.1.4", "vue-property-decorator": "^5.0.1", "vue-router": "^2.3.0", "vue-template-compiler": "^2.2.2", "webpack": "^2.2.0", "webpack-hot-middleware": "^2.12.2" } And within the `ProjectName.Web.csproj`: <ItemGroup> <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" /> <PackageReference Include="jQuery" Version="3.2.1" /> </ItemGroup> I installed Install `jQuery` and its type definitions using `npm install --save jquery @types/jquery`. I then attempt to import `jQuery` into my `Typescript` file using `import * as $ from 'jquery';` That produces an error: `Could not find a declaration file for module 'jquery'. {project_path}/node_modules/jquery/dist/jquery.js' implicitly has an 'any' type.` What setting am I missing in order to use `jQuery` for this template?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#239
No description provided.