【问题标题】:Install Typings require for Ionic2 applicationIonic2 应用程序需要安装类型
【发布时间】:2016-09-23 11:27:02
【问题描述】:

所以我正在研究 Ionice2 项目(这仍然是新的.. 差不多一周),我正在尝试按照下面的教程使用 PouchDB for LocalStorage。

教程: http://gonehybrid.com/how-to-use-pouchdb-sqlite-for-local-storage-in-ionic-2/

其中一个要求是使用以下命令安装require

typings install require --ambient --save

每当我尝试这个命令时,我都会得到错误

Unable to find "require" ("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,这个问题的可能原因是什么?

npm install typings --global

【问题讨论】:

  • 我成功地遵循了相同的教程,但是我使用了这个命令来安装类型:npm install -g typings 不确定它在功能上是否与您使用的相同。
  • @wilburrr90 我也试过了,但结果一样
  • @wilburrr90 您使用的是哪个操作系统?

标签: angular requirejs ionic2 pouchdb typescript-typings


【解决方案1】:

最近更新了打字。首先更新到最新版本的类型。

要安装 require.d.ts 文件,请使用 typings install dt~require --save --global

更多详情请参考https://github.com/typings/typings

【讨论】:

    【解决方案2】:

    不是对这个问题的直接回答,但我认为应该提及。 Typescript 团队最近添加了一种管理定义文件的内置方式。他们在npm 之上构建了@types 系统。整个目标是您不需要使用两个单独的包管理器,也不需要使用多个配置文件(以前是 package.jsontypings.json 等)。现在,这一切都在package.json 中进行管理。

    例如,如果您要安装 lodash。你只是:

    npm install --save lodash
    npm install --save @types/lodash
    

    你可以走了。两者都在您的package.json 中进行管理,您无需使用任何/// <reference-path path="blah-blah-blah">

    或者,正如微软所说,"The Future of Declaration Files"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-06
      相关资源
      最近更新 更多