我试图在我的ionic2应用程序中实现谷歌身份验证。我需要它在浏览器中工作。所以,我安装:Typescript错误,无法找到名称'gapi',transpile失败
npm install --save @types/gapi
npm install --save @types/gapi.auth2
有两个警告:
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected]^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
在node_modules文件夹我有GAPI和gapi.auth2文件夹,但我有打字稿错误:无法找到名为 'GAPI',transpile失败。
我安装
npm install typings -g
typings install dt~gapi --global --save
typings install dt~gapi.auth2 --global --save
仍然有同样的错误:无法找到名为 'GAPI',transpile失败
我的代码:
auth2: any;
login() {
gapi.load('auth2',() => {
this.auth2 = gapi.auth2.init({
client_id: 'xxxxxxxxx.apps.googleusercontent.com',
scope: 'https://www.googleapis.com/auth/userinfo.email'
});
});
};
我的package.json:
"@angular/core": "2.2.1",
"ionic-angular": "2.0.0-rc.4",
"ionic-native": "2.2.11",
"rxjs": "5.0.0-beta.12",
"typescript": "2.0.9"
谢谢你,为我工作! 请注意,在较新版本的angular-cli中,这些编辑的正确文件可能是tsconfig.app.json – Willy