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

后端 未结 10 821
梦谈多话
梦谈多话 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条回答
  • I just created a index.d.ts in my src folder and added

    declare module 'googlemaps';

    It solved the issue

    0 讨论(0)
  • 2020-12-04 14:44

    For me in Angular 6, it worked when I only used

    /// <reference types="@types/googlemaps" />
    
    0 讨论(0)
  • 2020-12-04 14:47

    The import can be simplified as follows:

    import {} from "googlemaps";
    

    Create a file at your projects root directory named index.d.ts and paste the following:

    declare module 'googlemaps';
    

    The created file needs to be located directory in the src folder

    I found this article about what is the purpose of that file

    https://www.bennadel.com/blog/3169-adding-custom-typings-files-d-ts-in-an-angular-2-typescript-application.htm

    0 讨论(0)
  • 2020-12-04 14:53

    In my Angular 7+ project

    $ npm install @types/googlemaps --save-dev
    In tsconfig.app.json

    "types": [
          "googlemaps"
    ]
    

    Thank you the link below https://www.freakyjolly.com/angular-7-6-add-google-maps-in-angular-2-plus-applications-using-angular-google-maps-module-agm-core-easily/#more-2316

    0 讨论(0)
提交回复
热议问题