eli2003
eli2003

Reputation: 400

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

Upvotes: 0

Views: 393

Answers (1)

Hithesh kumar
Hithesh kumar

Reputation: 1036

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

Upvotes: 1

Related Questions