我很困惑。我已经很长时间没有任何问题了,现在我突然无法部署了。我不记得做任何可能导致这种情况的事情。
我有3种不同的云功能。当我运行firebase deploy
时,每个错误似乎都是相同的:
! 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"}}
我用Google搜索,有人说要删除package-lock.json
,所以我做到了。我跑了npm install
,它给了我这些警告:
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'
然后我尝试了firebase deploy --only functions
,并且每个云函数都出现了此错误:
! 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"}}
为什么这突然发生了,我该怎么办才能解决?请帮忙。
答案 0 :(得分:3)
错误消息表明您的node_modules文件夹中缺少某些内容。删除整个node_modules文件夹,然后再次进行npm安装。
答案 1 :(得分:0)
这是一个非常愚蠢的,难以调试的错误。如果您有许多功能,则日志记录是加密的。
尝试以下任何一种方法:
package-lock.json
和node_modules
并运行npm install 对我来说,这是使事情再次动起来的第一个选择。我还重新初始化了firebase,重新安装了firebase-tools,并尝试了不同的节点版本,尽管我认为这些步骤没有什么不同。
答案 2 :(得分:0)
在functions目录中,同时安装firebase-functions和firebase-admin。
npm install firebase-functions 然后 npm install firebase-admin
然后部署您的功能 firebase deploy --only功能