7

I was following JSPM getting started guide and I want to install jquery package so I execute below command.

jspm install jquery

But when I try to import it in typescript like below

import $ from 'jquery'

I'm getting a error from typescript compiler saying error TS2307: Cannot find module 'jquery'. Not only for this library for other libraries I'm getting the same error.

Vadim Macagon
  • 14,463
  • 2
  • 52
  • 45
Shabith
  • 3,005
  • 3
  • 23
  • 20

2 Answers2

5

You need to include type definitions for jquery in the compilation context, you can grab them from https://github.com/DefinitelyTyped/DefinitelyTyped

Vadim Macagon
  • 14,463
  • 2
  • 52
  • 45
  • Thanks for the help. What if that module type definition file is not available there? – Shabith Jan 31 '16 at 05:54
  • 1
    Then I'd check https://github.com/typings/typings/ and if that doesn't have them then you'll have to write your own type definitions. When writing type definitions you don't have to define the entire API at once, you can just define the bits you're using. And if you just want to use a lib without type definitions you can do so with `declare module 'somelib' { var a: any; export = a; }`. – Vadim Macagon Jan 31 '16 at 06:11
-1

I encountered on exactly same kind of error during VSBuild on Azure DevOps.

In my case, solution was just add new extra step Install npm into build pipeline and error was gone.

AzureDevOps Step

I hope it will help somebody!

Tomanek1
  • 65
  • 4