打字稿不能ionic2
typings install google.maps --save
下面也给出了同样的错误打字稿不能ionic2
typings install google.maps --ambient
typings install google.maps --global
分型ERR安装具有分型google.maps!消息无法在 注册表中找到“google.maps”(“npm”)。你想尝试搜索另一个来源吗?另外,如果您想要提供这些类型,请帮助我们: github.com/typings/registry typings ERR!引起 https://api.typings.org/entries/npm/google.maps/versions/latest 回复404,预计它等于200
typings ERR! cwd/Users/jeswinjames24/Work/xyz类型ERR!系统 达尔文15.3.0类型ERR!命令“/ usr/local/bin/node” “/ usr/local/bin/typings”“install”“google.maps”“--save”typings ERR! 节点-v v4.3.1类型ERR! typings -v 1.0.3
typings ERR!如果您需要帮助,您可以在以下网址报告此错误:typings ERR! github.com/typings/typings/issues的MacBook-PRO:xyzjeswinjames24 $ NPM安装谷歌,地图XYZ @ /用户/ jeswinjames24 /工作/ XYZ
这在typings 1.0.0改变其中--ambient
更名为--global
。
您还需要明确说明安装源以覆盖默认值(即npm)。看起来你需要从DefinitelyTyped(DT)源安装谷歌,地图类型定义:
[[email protected] 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
你也可以试试这个:
typings install github:DefinitelyTyped/DefinitelyTyped/googlemaps/google.maps.d.ts --global --save
由于上述方法都不适用于我,我直接从GitHub安装了Google Maps TypeScript定义!
为了让您的应用程序找到您安装了typings的库,您需要让编译器达到类型并编译它们。要做到这一点,包括分型路径(“分型/ * d.ts”)在您的tsconfig.json
我测试了我的离子2项目下面的步骤,它是完美的作品:
1-安装分型全球:
npm install typings --global
2-安装谷歌。通过分型
typings install dt~google.maps --global --save
3-开放tsconfig.json并添加地图 “分型/ *。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
}
}
检查了这一点: -
离子科尔多瓦插件添加科尔多瓦 - 插件 - 谷歌地图