Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
630 views
in Technique[技术] by (71.8m points)

typescript - Firebase cloud functions code ELIFECYCLE error

When trying to deploy the initial code provided by firebase init for cloud functions by calling firebase deploy the following error occurs. The source code inside index.ts has not been modified as it is the case with the rest of the project.

Running command: npm --prefix "$RESOURCE_DIR" run build

> functions@ build /Users/eliasdolinsek/development/firebase-development/functions
> tsc

../../../node_modules/@types/fs-extra/index.d.ts:195:87 - error TS2694: Namespace '"fs"' has no exported member 'Dir'.

195 export function opendir(path: string, cb: (err: NodeJS.ErrnoException | null, dir: fs.Dir) => void): void;
                                                                                          ~~~

../../../node_modules/@types/fs-extra/index.d.ts:198:17 - error TS2694: Namespace '"fs"' has no exported member 'OpenDirOptions'.

198     options: fs.OpenDirOptions,
                    ~~~~~~~~~~~~~~

../../../node_modules/@types/fs-extra/index.d.ts:199:53 - error TS2694: Namespace '"fs"' has no exported member 'Dir'.

199     cb: (err: NodeJS.ErrnoException | null, dir: fs.Dir) => void,
                                                        ~~~

../../../node_modules/@types/fs-extra/index.d.ts:201:52 - error TS2694: Namespace '"fs"' has no exported member 'OpenDirOptions'.

201 export function opendir(path: string, options?: fs.OpenDirOptions): Promise<fs.Dir>;
                                                       ~~~~~~~~~~~~~~

../../../node_modules/@types/fs-extra/index.d.ts:201:80 - error TS2694: Namespace '"fs"' has no exported member 'Dir'.

201 export function opendir(path: string, options?: fs.OpenDirOptions): Promise<fs.Dir>;
                                                                                   ~~~


Found 5 errors.

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! functions@ build: `tsc`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the functions@ build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/eliasdolinsek/.npm/_logs/2021-01-26T13_18_50_649Z-debug.log

Error: functions predeploy error: Command terminated with non-zero exit code2
question from:https://stackoverflow.com/questions/65902237/firebase-cloud-functions-code-elifecycle-error

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

add typeRoots to the tsconfig.json within the functions folder

{
  "compilerOptions": {
    "module": "commonjs",
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "outDir": "lib",
    "sourceMap": true,
    "strict": true,
    "target": "es2017",
    "typeRoots": [
      "./functions/node_modules/@types"
    ],
  },
  "compileOnSave": true,
  "include": [
    "src"
  ],
}

check out this Github issues


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...