Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
28
rated 0 times [  32] [ 4]  / answers: 1 / hits: 21711  / 7 Years ago, wed, june 28, 2017, 12:00:00

The statement



 x = $('#msgBox_' + scope.boxId).position().left;


generates an




error TS2304: Cannot find name '$'




although jquery and @types are installed in the node_modules folder.



My tsconfig.json looks like that:



{
compilerOptions: {
module: commonjs,
target: es5,
sourceMap: true,
moduleResolution: node,
declaration: true
},
exclude: [
node_modules
]
}


How can I fix that?


More From » node.js

 Answers
39

Turns out I was missing the @types/jquery node module, which contains a definition of $. Once I added @types/jquery: ^3.2.5 to the list of devDependencies in my package.json and reinstalled via npm install, everything worked fine.


[#57281] Sunday, June 25, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tai

Total Points: 466
Total Questions: 87
Total Answers: 116

Location: Saint Helena
Member since Tue, Nov 3, 2020
4 Years ago
;