Pau*_*ton 6 google-api node.js typescript
我正在使用 Typescript、tslint 和 Google API,但是在将 typescript 编译为 javascript 时出现问题,我不确定为什么,出于某种原因,我在网上找不到有关此问题的任何具体信息。谷歌搜索不会产生好的结果。我也找不到一个很好的例子来说明你的 tsconfig 应该如何使用这个库进行设置。所以我来这里。
当我运行tsc
.
我的文件实际上就是这一行:
import {google} from 'googleapis'
就是这样。
当我运行tsc
它给我这些错误:
$ tsc
node_modules/gaxios/build/src/common.d.ts:1:23 - error TS2688: Cannot find type definition file for 'node'.
1 /// <reference types="node" />
~~~~
node_modules/gaxios/build/src/common.d.ts:3:23 - error TS2307: Cannot find module 'https'.
3 import { Agent } from 'https';
~~~~~~~
node_modules/google-auth-library/build/src/auth/authclient.d.ts:16:23 - error TS2688: Cannot find type definition file for 'node'.
16 /// <reference types="node" />
~~~~
node_modules/google-auth-library/build/src/auth/authclient.d.ts:17:30 - error TS2307: Cannot find module 'events'.
17 import { EventEmitter } from 'events';
~~~~~~~~
node_modules/google-auth-library/build/src/auth/googleauth.d.ts:16:23 - error TS2688: Cannot find type definition file for 'node'.
16 /// <reference types="node" />
~~~~
node_modules/google-auth-library/build/src/auth/googleauth.d.ts:17:21 - error TS2307: Cannot find module 'fs'.
17 import * as fs from 'fs';
~~~~
node_modules/google-auth-library/build/src/auth/googleauth.d.ts:19:25 - error TS2307: Cannot find module 'stream'.
19 import * as stream from 'stream';
~~~~~~~~
node_modules/google-auth-library/build/src/auth/googleauth.d.ts:182:20 - error TS2503: Cannot find namespace 'NodeJS'.
182 _osPlatform(): NodeJS.Platform;
~~~~~~
node_modules/google-auth-library/build/src/auth/jwtaccess.d.ts:16:23 - error TS2688: Cannot find type definition file for 'node'.
16 /// <reference types="node" />
~~~~
node_modules/google-auth-library/build/src/auth/jwtaccess.d.ts:17:25 - error TS2307: Cannot find module 'stream'.
17 import * as stream from 'stream';
~~~~~~~~
node_modules/google-auth-library/build/src/auth/jwtclient.d.ts:16:23 - error TS2688: Cannot find type definition file for 'node'.
16 /// <reference types="node" />
~~~~
node_modules/google-auth-library/build/src/auth/jwtclient.d.ts:18:25 - error TS2307: Cannot find module 'stream'.
18 import * as stream from 'stream';
~~~~~~~~
node_modules/google-auth-library/build/src/auth/refreshclient.d.ts:16:23 - error TS2688: Cannot find type definition file for 'node'.
16 /// <reference types="node" />
~~~~
node_modules/google-auth-library/build/src/auth/refreshclient.d.ts:17:25 - error TS2307: Cannot find module 'stream'.
17 import * as stream from 'stream';
~~~~~~~~
node_modules/google-auth-library/build/src/crypto/crypto.d.ts:16:23 - error TS2688: Cannot find type definition file for 'node'.
16 /// <reference types="node" />
~~~~
node_modules/google-auth-library/build/src/crypto/crypto.d.ts:32:60 - error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
32 verify(pubkey: string | JwkCertificate, data: string | Buffer, signature: string): Promise<boolean>;
Run Code Online (Sandbox Code Playgroud)
我的 tsconfig 文件是:
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"esModuleInterop": true,
"noImplicitAny": false,
"moduleResolution": "node",
"sourceMap": true,
"outDir": "app",
"baseUrl": "./app",
"paths": {
"*": [
"node_modules/*"
]
}
},
"include": [
"src/**/*"
]
}
Run Code Online (Sandbox Code Playgroud)
我的包依赖项是:
"dependencies": {
"googleapis": "^37.2.0",
"mysql": "^2.16.0",
"typescript": "^3.3.3333"
},
"devDependencies": {
"nodemon": "^1.18.10",
"tslint": "^5.12.1"
}
Run Code Online (Sandbox Code Playgroud)
我没有使用 tsc 节点模块(已弃用),我使用的是 typescript v3.3.3
帮助将不胜感激!:)
归档时间: |
|
查看次数: |
1517 次 |
最近记录: |