Cannot find type definition file for 'jquery'

General Discussion
  • Hello,

    I'm getting an error in Visual Studio 2015 when I try to compile my WebAPI project:

    "Cannot find type definition file for 'jquery'"

    I'm setting up my project using node.js.

    The main folder for the project is RiskAlive9, and under that folder is a set of sub-projects:

    -Core
    -Database
    -Test
    -Web
    -WebAPI

    Everything compiles properly except for WebAPI which is giving me the error above.

    Here's how I installed node, bower, and typescript:

    npm install

    This created a node_modules folder in the main folder (RiskAlive9).

    npm install -g bower

    This installed bower, gulp, and a bunch of pluggins for gulp.

    bower install

    This created a bower_components folder in the main folder (RiskAlive9).

    npm install [email protected]

    This installed typescript 2.4.1

    npm install "@types/jquery"

    This created a @types folder in the node_modules folder with a jquery folder inside it.

    Yet WebAPI is still saying it cannot find the type definition file for jquery.

    So I tried copying node_modules into the WebAPI folder. This fixed 99% of the errors (cannot find type definition file was not the only one), but also brought up a few new errors.

    I'm wondering: does installing node typically mean installing it for every project in your solution (such that each sub-folder that needs to use node will have a node_modules folder)? Or isn't there a way to get all projects in your solution to use the main node_modules folder?

  • Check you typeSources array in tsconfig.json, makes ure it's either not defined, or includes node_modules/@types

    Just FYI, this forum is for the Node.js based forum software NodeBB, it's not really a forum for help with general Node.js or TypeScript issues. A better place for that is SlackOverflow.

  • Here is my tfconfig.json file:

    {
    "compilerOptions": {
    "baseUrl": "./src",
    "noEmitOnError": true,
    "noImplicitAny": true,
    "outDir": "./scripts/bowtie",
    "outFile": "./scripts/bowtie/bowtie.js",
    "sourceMap": false,
    "declaration": false,
    "target": "es5",
    "typeRoots": [
    "node_modules/@types"
    ],
    "types": [
    "jquery",
    "d3"
    ]
    },
    "exclude": [
    "obj",
    "node_modules",
    "WebAPI/node_modules",
    "scripts/bowtie",
    "../node_modules/"
    ],
    "compileOnSave": true
    }

    Doesn't have typeSources at all.

    It's in the WebAPI folder. Is this the right place for it?

    If I were to let typeSources be undefined, would this be the right way to do it:

    {
    "compilerOptions": {
    "baseUrl": "./src",
    "noEmitOnError": true,
    "noImplicitAny": true,
    "outDir": "./scripts/bowtie",
    "outFile": "./scripts/bowtie/bowtie.js",
    "sourceMap": false,
    "declaration": false,
    "target": "es5",
    "typeRoots": [
    "node_modules/@types"
    ],
    "types": [
    "jquery",
    "d3"
    ]
    },
    "typeSources": "undefined",
    "exclude": [
    "obj",
    "node_modules",
    "WebAPI/node_modules",
    "scripts/bowtie",
    "../node_modules/"
    ],
    "compileOnSave": true
    }

    If I were to add "@types/jquery" to the file, would this be the right way to do it?

    {
    "compilerOptions": {
    "baseUrl": "./src",
    "noEmitOnError": true,
    "noImplicitAny": true,
    "outDir": "./scripts/bowtie",
    "outFile": "./scripts/bowtie/bowtie.js",
    "sourceMap": false,
    "declaration": false,
    "target": "es5",
    "typeRoots": [
    "node_modules/@types"
    ],
    "types": [
    "jquery",
    "d3"
    ]
    },
    "typeSources": ["node_modules/@types"],
    "exclude": [
    "obj",
    "node_modules",
    "WebAPI/node_modules",
    "scripts/bowtie",
    "../node_modules/"
    ],
    "compileOnSave": true
    }

    "Just FYI, this forum is for the Node.js based forum software NodeBB, it's not really a forum for help with general Node.js or TypeScript issues. A better place for that is SlackOverflow."

    Thanks for helping out even though this isn't the right forum for this kind of question. Ironically, stackoverflow is NOT a better place for this kind of question because no one ever replies even when I'm perfectly on topic.

    Do you know any forums specific to node?

  • @gib96 I meant typeRoots, and by making it undefined, I didn't mean setting it to the string "undefined", I meant not defining it at all.


Suggested Topics


  • 0 Votes
    6 Posts
    328 Views

    @gotwf thanks,I didn't use 14x, I reduced my version to 12x, and then my pictures could be uploaded normally

  • 1 Votes
    5 Posts
    919 Views

    I'm running an educational forum (https://szkolnecentrum.pl), and, in the first place, I would like to change the names of particular elements. For example, instead of "topic" or "post", I would like to name it "task", "assignment", "answer" or anything like this. More importantly, there is an issue connected to one of the plugins and some part of HTML can be seen in notifications (screen below).
    mistake.png
    The plugin which is responsible for that error is called nodebb-plugin-question-and-answer-pl (all the plugins don't work except the Chinese one, that's why I would also like to access HTML and try changing it).

  • 1 Votes
    4 Posts
    1k Views

    I've been able to reproduce this. Working on finding the bug right now.

  • Find by Slug or Create

    General Discussion
    0 Votes
    3 Posts
    2k Views

    If there were multiple topics with the same slug I would show the user a list of those topics with a summary text of the body content and allow them to click on the one they want to read.

    Anyone know of some sample code to find a list of topics based on the slug?

  • 1 Votes
    23 Posts
    10k Views

    I am running 2 nodebb installs on a 256 MB ramnode vps it is surprisingly smooth as you would guess from my sig 😆