Typescript Compiler error TS2307: Cannot find modu

2019-04-07 01:31发布

问题:

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.

回答1:

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