TypeError:无法读取未定义的“需要”属性:

dse*_*ing 22 node.js firebase google-cloud-functions firebase-cli

我整天都在成功地使用Firebase部署功能,学习如何使用它。我试图查看如果初始化了另一个部署到同一项目的目录并且在更新npm版本之前没有任何问题的情况,直到我更新npm版本时发生了什么,现在我每次尝试部署时都收到“发生意外错误”

我尝试通过使自己的用户成为node_modules,bin和共享目录的所有者来更新npm权限。我尝试卸载并重新安装firebase-tools。我还尝试删除所有当前函数目录并初始化一个新目录,然后在其中重新安装我的依赖项。

这是调试日志

Dylans-MacBook-Pro-3:functions dsenderling$ firebase deploy --debug
[2019-07-03T18:04:35.526Z] ----------------------------------------------------------------------
[2019-07-03T18:04:35.528Z] Command:       /usr/local/bin/node /usr/local/bin/firebase deploy --debug
[2019-07-03T18:04:35.529Z] CLI Version:   7.0.2
[2019-07-03T18:04:35.529Z] Platform:      darwin
[2019-07-03T18:04:35.529Z] Node Version:  v10.16.0
[2019-07-03T18:04:35.529Z] Time:          Wed Jul 03 2019 13:04:35 GMT-0500 (Central Daylight Time)
[2019-07-03T18:04:35.529Z] ----------------------------------------------------------------------

[2019-07-03T18:04:35.537Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2019-07-03T18:04:35.537Z] > authorizing via signed-in user
[2019-07-03T18:04:35.537Z] [iam] checking project my-awesome-project-5a4e9 for permissions ["cloudfunctions.functions.create","cloudfunctions.functions.delete","cloudfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functions.update","cloudfunctions.operations.get","firebase.projects.get"]
[2019-07-03T18:04:35.539Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/my-awesome-project-5a4e9:testIamPermissions  
 permissions=[cloudfunctions.functions.create, cloudfunctions.functions.delete, cloudfunctions.functions.get, cloudfunctions.functions.list, cloudfunctions.functions.update, cloudfunctions.operations.get, firebase.projects.get]
[2019-07-03T18:04:35.769Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Wed, 03 Jul 2019 18:04:35 GMT, server=ESF, cache-control=private, x-xss-protection=0, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, server-timing=gfet4t7; dur=83, alt-svc=quic=":443"; ma=2592000; v="46,43,39", accept-ranges=none, transfer-encoding=chunked
[2019-07-03T18:04:37.033Z] TypeError: Cannot read property 'wanted' of undefined
    at /usr/local/lib/node_modules/firebase-tools/lib/checkFirebaseSDKVersion.js:37:51
    at process._tickCallback (internal/process/next_tick.js:68:7)

Error: An unexpected error has occurred.
Run Code Online (Sandbox Code Playgroud)

我的直觉告诉我firebase-tools或firebase sdk出了点问题,但我不知道是什么原因。提前致谢

Rus*_*ora 34

出现了完全相同的问题,将npm从6.9.2更新为6.10.0之后就开始了。

最终降级到6.9.2(npm install -g npm@6.9.2),我的Firebase部署立即又开始工作。

编辑:firebase部署正在使用npm 6.10.1,现在可以安全更新!


bem*_*mpa 8

我认为此问题是由npm 6.10.0中的修复引起的,请参阅https://github.com/npm/cli/pull/176

解决方法是修改/usr/lib/node_modules/firebase-tools/lib/checkFirebaseSDKVersion.js(linux)。对于macOS和nvm,请参阅以下注释。

从:

if (!output) {
  return;
}
Run Code Online (Sandbox Code Playgroud)

至:

if (!output || !output["firebase-functions"]) {
  return;
}
Run Code Online (Sandbox Code Playgroud)