@types/googlemaps/index.d.ts' is not a module

后端 未结 10 852
梦谈多话
梦谈多话 2020-12-04 14:25

I want to use the Google Maps API with my Angular project, so I used these two commands to install npm packages:

npm install @agm/core --save-dev
npm install         


        
10条回答
  •  醉酒成梦
    2020-12-04 14:41

    Thanks to this documentation link : https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html

    [Angular 6+] You only have to add this line at the beginning (meaning line 1, with nothing before) of your Typescript file :

    /// 
    

    [Angular 5-] You only have to add this line anywhere in your Typescript file imports :

    import {} from "googlemaps";
    

    Thanks to the answer below, you may also need to add a file /index.d.ts containing (didn't need it though in my case) :

    declare module 'googlemaps';
    

提交回复
热议问题