打开“esModuleInterop”标志

chr*_*psv 9 firebase google-cloud-functions

我正在为我的应用程序使用 Firebase Functions。我在我的电脑上安装了这些 firebase 功能,但无法使用以下命令:

Firebase 部署——仅功能

我收到以下错误:

node_modules/google-gax/build/protos/iam_service.d.ts:17:23 - error TS2497: This module 
can only be referenced with ECMAScript imports/exports by turning on the 
'esModuleInterop' flag and referencing its default export.

17 import * as Long from 'long';
                       ~~~~~~

node_modules/google-gax/build/protos/operations.d.ts:17:23 - error TS2497: This module 
can only be referenced with ECMAScript imports/exports by turning on the 
'esModuleInterop' flag and referencing its default export.

17 import * as Long from 'long';
                         ~~~~~~

Found 2 errors in 2 files.

Errors  Files
 1  node_modules/google-gax/build/protos/iam_service.d.ts:17
 1  node_modules/google-gax/build/protos/operations.d.ts:17

Error: functions predeploy error: Command terminated with non-zero exit code2
Run Code Online (Sandbox Code Playgroud)

有谁知道如何打开这个标志?

小智 12

只需添加"skipLibCheck": true到您的tsconfig.json,如下所示:

"compilerOptions": {
    "module": "commonjs",
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "outDir": "lib",
    "sourceMap": true,
    "strict": true,
    "target": "es2017",
    "skipLibCheck": true
  },
Run Code Online (Sandbox Code Playgroud)