简体   繁体   中英

Firebase deploy cloud functions suddenly doesn't work anymore

I am very confused. I've had no problems at all for a long time, and now I suddenly can't deploy anymore. I can't remember doing anything that could have caused this.

I have 3 different cloud functions. When I ran firebase deploy I got what seemed to be the same error for each one:

!  functions[generateThumbs(europe-west1)]: Deployment error.
Build failed: {"error": {"canonicalCode": "INVALID_ARGUMENT", "errorMessage": "`npm_install` had stderr output:\nnpm WARN tar ENOENT: no such file or directory, lstat '/workspace/node_modules/.staging/sharp-261f9e9e/docs/image'\nnpm WARN tar ENOENT: no such file or directory, open '/workspace/node_modules/.staging/firebase-admin-a1197e24/lib/auth/token-verifier.js'\nnpm WARN tar ENOENT: no such file or directory, open '/workspace/node_modules/.staging/@types/lodash-973f4ada/common/math.d.ts'\nnpm WARN tar ENOENT: no such file or directory, open '/workspace/node_modules/.staging/sharp-261f9e9e/docs/index.md'\nnpm WARN tar ENOENT: no such file or directory, open '/workspace/node_modules/.staging/@types/lodash-973f4ada/common/number.d.ts'\nnpm WARN tar ENOENT: no such file or directory, open '/workspace/node_modules/.staging/@types/lodash-973f4ada/common/object.d.ts'\nnpm WARN tar ENOENT: no such file or directory, open '/workspace/node_modules/.staging/@google-cloud/storage-66ff4fa1/build/src/channel.d.ts'\nnpm WARN tar ENOENT: no such file or directory, open '/workspace/node_modules/.staging/@google-cloud/storage-66ff4fa1/build/src/channel.js'\nnpm WARN tar ENOENT: no such file or directory, open '/workspace/node_modules/.staging/express-5648fc3a/index.js'\nnpm WARN tar ENOENT: no such file or directory, open '/workspace/node_modules/.staging/@google-cloud/storage-66ff4fa1/build/src/file.d.ts'\nnpm WARN tar ENOENT: no such file or directory, open '/workspace/node_modules/.staging/express-5648fc3a/LICENSE'\nnpm WARN tar ENOENT: no such file or directory, open '/workspace/node_modules/.staging/tar-253f970f/lib/update.js'\nnpm WARN tar ENOENT: no such file or directory, open '/workspace/node_modules/.staging/express-5648fc3a/Readme.md'\nnpm WARN tar ENOENT: no such file or directory, open '/workspace/node_modules/.staging/tar-253f970f/lib/warn-mixin.js'\nnpm WARN tar ENOENT: no such file
or directory, open '/workspace/node_modules/.staging/tar-253f970f/lib/winchars.js'\nnpm WARN tar ENOENT: no such file or directory, open '/workspace/node_modules/.staging/tar-253f970f/lib/write-entry.js'\nnpm WARN tar ENOENT: no such file or directory, open '/workspace/node_modules/.staging/xregexp-5f45e5d3/MIT-LICENSE.txt'\nnpm WARN tar ENOENT: no such file or directory, open '/workspace/node_modules/.staging/ast-types-c8750e07/gen/namedTypes.js'\nnpm WARN tar ENOENT: no such file or directory, open '/workspace/node_modules/.staging/ast-types-c8750e07/gen/nodes.d.ts'\nnpm ERR! code E404\nnpm ERR! 404 Not Found: websocket-driver@0.7.2\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR!     /builder/home/.npm/_logs/2019-06-21T23_38_41_651Z-debug.log\n\nerror: `npm_install` returned code: 1", "errorType": "InternalError", "errorId": "1A98E1A1"}}

I googled, and someone said to delete package-lock.json , so i did. I ran npm install and it gave me these warnings:

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Jesper\intergun\functions\node_modules\concat-stream\node_modules\isarray\package.json'
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Jesper\intergun\functions\node_modules\firebase-functions\node_modules\ms\package.json'
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Jesper\intergun\functions\node_modules\through2\node_modules\isarray\package.json'

Then i tried firebase deploy --only functions , and I got this error for each cloud function:

!  functions[generateThumbs(europe-west1)]: Deployment error.
Build failed: {"error": {"canonicalCode": "INVALID_ARGUMENT", "errorMessage": "`npm_install` had stderr output:\nnpm ERR! Cannot read property 'match' of undefined\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR!     /builder/home/.npm/_logs/2019-06-21T23_51_11_275Z-debug.log\n\nerror: `npm_install` returned code: 1", "errorType": "InternalError", "errorId": "70391B03"}}

Why is this suddenly happening, and what can I do to fix it? Please help.

The error messages are saying there are things missing in your node_modules folder. Delete the entire node_modules folder, then npm install again.

This is a very stupid, hard-to-debug error. The logging is cryptographic if you have many functions.

Try any of the following:

  • Using node 8 instead of node 10 (though recently fixed internally, I have found there are still issues with node 10)
  • Check for possible corrupted or recently-installed dependencies, and remove
  • Nuking package-lock.json and node_modules and running npm install

For me, it was the first option that got things in motion again. I also re-initialised firebase, reinstall firebase-tools and tried different node versions, though I don't think these steps made any difference.

On your functions directory, install both firebase-functions and then firebase-admin.

npm install firebase-functions then npm install firebase-admin

Then deploy your functions firebase deploy --only functions

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM