Google Cloud Debugger 无法在 Node.js 上运行

Google Cloud Debugger not working on Node.js

我的 Node.js API 服务在标准环境中托管在 google 云 App Engine 运行 上。 我已执行所有步骤,但调试代理抛出以下消息:

@google-cloud/debug-agent 无法重新注册调试对象 xxx-backend:错误:位于 { 的文件不存在,或者它不是文件。 ENOENT:没有这样的文件或目录,lstat '/workspace/{'

我的 app.ts 文件顶部有这段代码: require('@google-cloud/debug-agent').start();

我的Node.js版本是:14.17.0

更新软件包并再次安装后,错误为:

Error: The file at { does not exist, or it is not a file. ENOENT: no such file or directory, lstat '/workspace/{' at Object.realpathSync (fs.js:1796:7) at GoogleAuth._getApplicationCredentialsFromFilePath (/workspace/node_modules/google-auth-library/build/src/auth/googleauth.js:263:27) at GoogleAuth._tryGetApplicationCredentialsFromEnvironmentVariable (/workspace/node_modules/google-auth-library/build/src/auth/googleauth.js:206:25) at GoogleAuth.getApplicationDefaultAsync (/workspace/node_modules/google-auth-library/build/src/auth/googleauth.js:136:24) at GoogleAuth.getClient (/workspace/node_modules/google-auth-library/build/src/auth/googleauth.js:551:28) at GrpcClient._getCredentials (/workspace/node_modules/@google-cloud/logging/node_modules/google-gax/build/src/grpc.js:145:40) at GrpcClient.createStub (/workspace/node_modules/@google-cloud/logging/node_modules/google-gax/build/src/grpc.js:308:34) at processTicksAndRejections (internal/process/task_queues.js:95:5)

好的,所以我通过尝试一些东西得到了答案。基本上,我的秘密里有 GOOGLE_APPLICATION_CREDENTIALS。 我的应用程序部署在 GAE 中,因此我不需要凭据。我之前使用另一个应用程序进行托管,所以我把它藏在我的秘密里。 一旦我 删除了那个秘密 它就开始工作了。

但是为什么会出现这个错误呢?凭据是正确的,所以无论如何它都应该有效,对吗?

环境变量 GOOGLE_APPLICATION_CREDENTIALS 用于为您的应用程序代码提供身份验证凭据。

如果在 Google Cloud Platform 上启用了 Stackdriver Debugger API 访问范围,Stackdriver Debugger Agent 无需手动为实例 运行 提供身份验证凭据即可工作。对于 Google App Engine 实例,如果已为您的项目启用调试器 API(这是默认设置),则这是自动的。如果您在其他地方 运行,例如本地、本地或其他云提供商,则需要手动提供凭据。有关详细信息,请参阅文档。

您将环境变量 GOOGLE_APPLICATION_CREDENTIALS 设置为文件“{”,这就是您收到错误的原因。

看起来您是 运行 Google Cloud Platform 上的代码,这就是您的代码在删除 环境变量 GOOGLE_APPLICATION_CREDENTIALS.