question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error while using GAPI. Cannot find namespace 'gapi'.

See original GitHub issue

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

@angular/cli: 1.0.0 node: 7.4.0 os: darwin x64 @angular/common: 4.0.1 @angular/compiler: 4.0.1 @angular/core: 4.0.1 @angular/forms: 4.0.1 @angular/http: 4.0.1 @angular/platform-browser: 4.0.1 @angular/platform-browser-dynamic: 4.0.1 @angular/router: 4.0.1 @angular/cli: 1.0.0 @angular/compiler-cli: 4.0.1

Repro steps.

I have an existing app that uses google’s ‘gapi’ and ‘gapi.auth2.’ Installed using the following package.json: “dependencies”: { “@angular/common”: “^4.0.0”, “@angular/compiler”: “^4.0.0”, “@angular/core”: “^4.0.0”, “@angular/forms”: “^4.0.0”, “@angular/http”: “^4.0.0”, “@angular/platform-browser”: “^4.0.0”, “@angular/platform-browser-dynamic”: “^4.0.0”, “@angular/router”: “^4.0.0”, “@types/gapi”: “0.0.31”, “@types/gapi.auth2”: “0.0.35”, “core-js”: “^2.4.1”, “rxjs”: “^5.1.0”, “zone.js”: “^0.8.4”, “ng2-bootstrap”: “1.6.0”, “angular2-jwt”: “^0.2.0”, “bootstrap”: “3.2.0”, “ng2-nouislider”: “^1.5.2”, “nouislider”: “^9.2.0”, “moment”: “2.18.1” }, “devDependencies”: { “@angular/cli”: “1.0.0”, “@angular/compiler-cli”: “^4.0.0”, “@types/jasmine”: “2.5.38”, “@types/node”: “~6.0.60”, “@types/jwt-decode”: “^1.4.28”, “codelyzer”: “~2.0.0”, “jasmine-core”: “~2.5.2”, “jasmine-spec-reporter”: “~3.2.0”, “karma”: “~1.4.1”, “karma-chrome-launcher”: “~2.0.0”, “karma-cli”: “~1.0.1”, “karma-jasmine”: “~1.1.0”, “karma-jasmine-html-reporter”: “^0.2.2”, “karma-coverage-istanbul-reporter”: “^0.2.0”, “protractor”: “~5.1.0”, “ts-node”: “~2.0.0”, “tslint”: “~4.5.0”, “typescript”: “~2.2.0” } }

running serve or build while trying to use the gapi as I have before: “private googleToken: gapi.auth2.AuthResponse;”

Throws an error saying the gapi namespace cannot be found.

This works fine when not using the cli.

The log given by the failure.

/my-app/src/app/security/components/google-sign-in/google-sign-in.ts (58,5): Cannot find name ‘gapi’

Desired functionality.

I’d like it to actually serve/build the application.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
daviatorstormcommented, Mar 2, 2018

Found a solution! Just add types to tsconfig.app.json

{
  "compilerOptions": {
    "types": ["gapi", "gapi.auth2"]
  }
}

https://stackoverflow.com/questions/38091215/import-gapi-auth2-in-angular-2-typescript

0reactions
angular-automatic-lock-bot[bot]commented, Sep 8, 2019

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular 2+ Error: Cannot find name 'gapi' - Stack Overflow
To use gapi a with Angular, install the type script definitions using NPM. ... The part you and I were missing is the...
Read more >
Typescript Error Cannot find name 'gapi' - ionic-v3
I trying to implement google short api in my ionic app. So, I wrote the following code: home.ts export class HomePage { longurl:any; ......
Read more >
Has anyone tried to use google sign in and GAPI with ... - Reddit
I'm transferring my project from gulp/system js into the CLI structure and I cannot get the gapi to be recognised whatsoever.
Read more >
@types/gapi.auth2 - npm
Summary. This package contains type definitions for Google Sign-In API (https://developers.google.com/identity/sign-in/web/).
Read more >
[Solved]-Angular 2+ Error: Cannot find name 'gapi'-angular.js
To use gapi a with Angular, install the type script definitions using NPM. npm install --save @types/gapi. also try adding to your compilerOptions:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found