2016-05-24 18 views
17

用于安装的jQuery:如何使用分型

typings install jquery --global 

typings ERR! message Unable to find "jquery" ("npm") in the registry. Did you want to try searching another source? Also, if you want contribute these typings, please help us: https://github.com/typings/registry 
typings ERR! caused by https://api.typings.org/entries/npm/jquery/versions/latest responded with 404, expected it to equal 200 

谁能帮我。

回答

30

尝试:

typings install dt~jquery --global --save 

编辑:

https://github.com/typings/typings#updating-from-0x-to-10

如果你想从DefinitelyTyped安装,是明确的(DT〜--global使用)。例如:分型安装DT〜角分量路由器--global --save

(见下文也Fidan的Hakaj的评论)

+1

但是究竟是什么意思? – Andrey

+1

@Andrey它代表DefinitelyTyped。 在typings README文件中看到:如果要从DefinitelyTyped安装,请明确指出(使用dt〜 --global)。 https://github.com/typings/typings#updating-from-0x-to-10 –

+0

现在该如何使用它?我仍然没有看到jquery * .ts文件 –

8

如果使用typescript2.0用命令:

NPM安装-g [email protected]

你可以用以下命令来安装的jQuery:

npm install --save @ types/jquery

+0

虽然这个工作,它会在全局变出$'变量,这对于使用它与很多其他类型的库。请参阅这里查看命名空间'$'作为'jquery'的潜在修复。 https://github.com/DefinitelyTyped/DefinitelyTyped/issues/11187 –