【问题标题】:Typescript cannot install google.maps with typings in ionic2Typescript 无法在 ionic2 中安装带有类型的 google.maps
【发布时间】:2016-09-13 00:37:01
【问题描述】:
typings install google.maps --save

以下也给出了同样的错误

typings install google.maps --ambient
typings install google.maps --global

打字错误!消息中无法找到“google.maps”(“npm”) 注册表。您想尝试搜索其他来源吗?另外,如果你 想贡献这些类型,请帮助我们: github.com/typings/registry 打字错误!引起的 https://api.typings.org/entries/npm/google.maps/versions/latest 以 404 响应,预计等于 200

打字错误! cwd /Users/jeswinjames24/Work/xyz 打字错误!系统 达尔文 15.3.0 分型错误!命令“/usr/local/bin/node” “/usr/local/bin/typings” “安装” “google.maps” “--save” 打字错误! node -v v4.3.1 打字错误!打字-v 1.0.3

打字错误!如果您需要帮助,您可以在以下位置报告此错误:typings 呃! github.com/typings/typings/issues MacBook-Pro:xyzjeswinjames24$ npm install google-maps xyz@ /Users/jeswinjames24/Work/xyz

【问题讨论】:

    标签: typescript


    【解决方案1】:

    这已在 typings 1.0.0 中进行了更改,其中 --ambient 已重命名为 --global

    您还需要明确说明要安装的源以覆盖默认值(即 npm)。看起来您需要从 DefinitiveTyped (dt) 源安装 google-maps 类型定义:

    [stewart@localhost cenode]$ typings search google-maps
    Viewing 2 of 2
    
    NAME                   SOURCE HOMEPAGE                                                                       DESCRIPTION VERSIONS UPDATED                 
    google-maps            dt     https://www.npmjs.com/package/google-maps                                                  1        2015-12-03T17:40:25.000Z
    google.maps.infobubble dt     http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobubble/src/             1        2016-03-17T12:06:54.000Z
    

    所以:

    typings install dt~google-maps --global

    【讨论】:

      【解决方案2】:

      你也可以试试这个:

      typings install github:DefinitelyTyped/DefinitelyTyped/googlemaps/google.maps.d.ts --global --save
      

      由于上述方法都不适合我,我直接从 GitHub 安装了 Google Maps TypeScript 定义!

      【讨论】:

        【解决方案3】:

        要让您的应用程序找到您安装的带有分型的库,您需要让编译器到达分型并编译它们。为此,请在 tsconfig.json 中包含类型路径(“typings/*.d.ts”)

        link

        我在我的 ionic 2 项目中测试了以下步骤,它运行良好:

        1- 全局安装typings

        npm install typings --global

        2- 通过打字安装 google.maps

        typings install dt~google.maps --global --save

        3- 打开 tsconfig.json 并将 "typings/*.d.ts" 添加到您的“包含”数组中,如下所示 (tsconfig.json)。

        {
          "compilerOptions": {
            "allowSyntheticDefaultImports": true,
            "declaration": false,
            "emitDecoratorMetadata": true,
            "experimentalDecorators": true,
            "lib": [
              "dom",
              "es2015"
            ],
            "module": "es2015",
            "moduleResolution": "node",
            "sourceMap": true,
            "target": "es5"
          },
          "include": [
            "src/**/*.ts",
            "typings/*.d.ts"
          ],
          "exclude": [
            "node_modules"
          ],
          "compileOnSave": false,
          "atom": {
            "rewriteTsconfig": false
          }
        }

        【讨论】:

          【解决方案4】:

          看看这个:-

          ionic cordova 插件添加 cordova-plugin-googlemaps

          【讨论】:

            猜你喜欢
            • 2017-06-19
            • 1970-01-01
            • 1970-01-01
            • 2018-01-23
            • 2016-09-23
            • 1970-01-01
            • 1970-01-01
            • 2018-06-30
            • 2019-07-17
            相关资源
            最近更新 更多