I have a lot of error when trying to reply my fibres functions.
Looks like it is related to lint
.
$ npm run deploy
> deploy
> firebase deploy --only functions
=== Deploying to 'shokaze-8cbe9'...
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
> functions@ lint /Users/stephanedeluca/development/shokaze/shokaze/functions
> eslint .
/Users/stephanedeluca/development/shokaze/shokaze/functions/dist/index.dev.js
7:497 error Unsafe usage of ThrowStatement no-unsafe-finally
73:10 error 'regeneratorRuntime' is not defined no-undef
74:12 error Unexpected constant condition no-constant-condition
The logs:
functions$ cat /Users/stephanedeluca/.npm/_logs/2023-11-30T21_18_47_713Z-debug.log
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/usr/local/bin/firebase',
1 verbose cli '/snapshot/firepit/node_modules/npm/bin/npm-cli',
1 verbose cli '--script-shell=/Users/stephanedeluca/.cache/firebase/runtime/shell',
1 verbose cli '--globalconfig=/Users/stephanedeluca/.cache/firebase/runtime/npmrc',
1 verbose cli '--userconfig=/Users/stephanedeluca/.cache/firebase/runtime/npmrc',
1 verbose cli '--scripts-prepend-node-path=auto',
1 verbose cli '--prefix',
1 verbose cli '/Users/stephanedeluca/development/shokaze/shokaze/functions',
1 verbose cli 'run',
1 verbose cli 'lint'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prelint', 'lint', 'postlint' ]
5 info lifecycle functions@~prelint: functions@
6 info lifecycle functions@~lint: functions@
7 verbose lifecycle functions@~lint: unsafe-perm in lifecycle true
8 verbose lifecycle functions@~lint: PATH: /snapshot/firepit/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/stephanedeluca/development/shokaze/shokaze/functions/node_modules/.bin:/Users/stephanedeluca/.cache/firebase/runtime:/Users/stephanedeluca/development/shokaze/shokaze/functions/node_modules/.bin:/Users/stephanedeluca/development/shokaze/shokaze/node_modules/.bin:/Users/stephanedeluca/development/shokaze/node_modules/.bin:/Users/stephanedeluca/development/node_modules/.bin:/Users/stephanedeluca/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/usr/local/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/Users/stephanedeluca/development/flutter/bin/:/Library/Frameworks/Python.framework/Versions/3.12/bin:/usr/local/opt/postgresql@11/bin:/Users/stephanedeluca/.rvm/gems/ruby-2.7.0/bin:/Users/stephanedeluca/.rvm/gems/ruby-2.7.0@global/bin:/Users/stephanedeluca/.rvm/rubies/ruby-2.7.0/bin:/opt/local/bin:/opt/local/sbin:/opt/homebrew/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/opt/X11/bin:/Library/Apple/usr/bin:/Library/TeX/texbin:/Applications/Wireshark.app/Contents/MacOS:/Users/stephanedeluca/development/flutter/bin/:/Library/Frameworks/Python.framework/Versions/3.12/bin:/Users/stephanedeluca/Downloads/google-cloud-sdk/bin:/usr/local/opt/postgresql@11/bin:/Users/stephanedeluca/.rvm/gems/ruby-2.7.0/bin:/Users/stephanedeluca/.rvm/gems/ruby-2.7.0@global/bin:/Users/stephanedeluca/.rvm/rubies/ruby-2.7.0/bin:/opt/local/bin:/opt/local/sbin:/opt/homebrew/bin:/Users/stephanedeluca/.rvm/bin:~/development/flutter/bin:/Users/stephanedeluca/.pub-cache/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:/Users/stephanedeluca/.rvm/bin:~/development/flutter/bin:/Users/stephanedeluca/.pub-cache/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin
9 verbose lifecycle functions@~lint: CWD: /Users/stephanedeluca/development/shokaze/shokaze/functions
10 silly lifecycle functions@~lint: Args: [ '-c', 'eslint .' ]
11 silly lifecycle functions@~lint: Returned: code: 1 signal: null
12 info lifecycle functions@~lint: Failed to exec lint script
13 verbose stack Error: functions@ lint: `eslint .`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/snapshot/firepit/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (node:events:527:28)
13 verbose stack at ChildProcess.<anonymous> (/snapshot/firepit/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (node:events:527:28)
13 verbose stack at maybeClose (node:internal/child_process:1092:16)
13 verbose stack at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
14 verbose pkgid functions@
15 verbose cwd /Users/stephanedeluca/development/shokaze/shokaze
16 verbose Darwin 23.1.0
17 verbose argv "/usr/local/bin/firebase" "/snapshot/firepit/node_modules/npm/bin/npm-cli" "--script-shell=/Users/stephanedeluca/.cache/firebase/runtime/shell" "--globalconfig=/Users/stephanedeluca/.cache/firebase/runtime/npmrc" "--userconfig=/Users/stephanedeluca/.cache/firebase/runtime/npmrc" "--scripts-prepend-node-path=auto" "--prefix" "/Users/stephanedeluca/development/shokaze/shokaze/functions" "run" "lint"
18 verbose node v16.16.0
19 verbose npm v6.14.17
20 error code ELIFECYCLE
21 error errno 1
22 error functions@ lint: `eslint .`
22 error Exit status 1
23 error Failed at the functions@ lint script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
2
Answers
I have finally found a fix.
For some reasons, removing my
dist
folder is the solution.And running
npm run deploy
again is now OK.You appear to be using the default configuration of a Firebase Functions project which will run
lint
, and your code is failing thelint
rules leading to the deploy failing.Either fix your code’s issues as described in the lint error output, or disable linting as part of the deployment process. See the
scripts
section ofpackage.json
in your "functions" project.I would recommend that you fix the linting errors, but in case you cannot do so right now, see this answer.