Cannot find type definition file for 'jquery'
-
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
-WebAPIEverything 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 includesnode_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.