小编Jav*_*ier的帖子

Angular 5导入谷歌gapi witn @types/gapi.auth2不起作用

我在 Angular 5 中有一个项目,我正在尝试使用 Google gapi.auth2 库实现登录。我被这个错误困住了:

ERROR in ./src/app/signin.service.ts
Module not found: Error: Can't resolve 'gapi.auth2' in 'C:\Users\Javier\workspace\angular-tour-of-heroes\src\app'
Run Code Online (Sandbox Code Playgroud)

该错误似乎与我在服务中导入库的方式有关。
我的实现包括"@types/gapi.auth2": "0.0.47",通过添加到 package.json 文件npm install --save @types/gapi.auth2。添加import gapi.auth2到signin.service.ts,这是我试图从中调用gapi的Angular服务。

包.json

{
 "name": "angular-tour-of-heroes",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --proxy-config proxy.conf.json",
    "build": "ng build --prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^5.2.5",
    "@angular/cdk": "^5.2.1",
    "@angular/common": "^5.2.5",
    "@angular/compiler": "^5.2.5",
    "@angular/core": "^5.2.5",
    "@angular/forms": …
Run Code Online (Sandbox Code Playgroud)

typescript google-signin angular

3
推荐指数
1
解决办法
5276
查看次数

标签 统计

angular ×1

google-signin ×1

typescript ×1