Jeswin James
Jeswin James

Reputation: 13

Typescript cannot install google.maps with typings in ionic2

typings install google.maps --save

the following also gives the same error

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

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

typings ERR! cwd /Users/jeswinjames24/Work/xyz typings ERR! system Darwin 15.3.0 typings ERR! command "/usr/local/bin/node" "/usr/local/bin/typings" "install" "google.maps" "--save" typings ERR! node -v v4.3.1 typings ERR! typings -v 1.0.3

typings ERR! If you need help, you may report this error at: typings ERR! github.com/typings/typings/issues MacBook-Pro:xyzjeswinjames24$ npm install google-maps xyz@ /Users/jeswinjames24/Work/xyz

Upvotes: 0

Views: 1488

Answers (4)

shivam trivedi
shivam trivedi

Reputation: 1

Check this out:-

ionic cordova plugin add cordova-plugin-googlemaps

Upvotes: -2

user2662006
user2662006

Reputation: 2294

To make your application find your libraries that you installed with typings, you need to make the compiler reach the typings and compiling them. to do that, include typings path ("typings/*.d.ts") in your tsconfig.json

link

I tested the following steps on my ionic 2 project and it is works perfectly:

1- install typings globally :

npm install typings --global

2- install google.maps via typings

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

3- open tsconfig.json and add "typings/*.d.ts" to your "include" array as shown below (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
  }
}

Upvotes: 1

Shmarkus
Shmarkus

Reputation: 188

You could also try this:

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

Since none of the above methods worked for me, I installed Google Maps TypeScript definitions directly from GitHub!

Upvotes: 1

Stewart Francis
Stewart Francis

Reputation: 735

This was changed in typings 1.0.0 where --ambient was renamed to --global.

You'll also need to explicitly state the source to install from to over-ride the default (which is npm). Looks like you'll need to install the google-maps type definitions from the DefinitelyTyped (dt) source:

[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

So:

typings install dt~google-maps --global

Upvotes: 4

Related Questions