谷歌云调试器不适用于 Node.js

问题描述

我的 Node.js API 服务托管在在标准环境中运行的 Google Cloud 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 用于为您的应用程序代码提供身份验证凭据。

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

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

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

,

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

但是为什么会出现这个错误呢?凭据是正确的,所以它应该可以正常工作,对吗?

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...