【问题标题】:Digital Signature of Google Cloud Function response message谷歌云函数响应消息的数字签名
【发布时间】:2019-12-01 05:46:11
【问题描述】:

我尝试使用 Google Cloud KMS 签署响应消息。

但是马上就报错了。

index.js:

// Imports the Google Cloud client library
const kms = require('@google-cloud/kms');

exports.helloKms = (req, res) => {
  let message = req.query.message || req.body.message || 'Hello World!';
  res.status(200).send(message);
};

package.json:

{
  "@google-cloud/kms": "^1.5.3",
  "name": "sample-http",
  "version": "0.0.1"
}

日志:

2019-12-01T05:26:37.534Z kms-demo Code in file index.js can't be loaded.
Did you list all required modules in the package.json dependencies?
Detailed stack trace: Error: Cannot find module '@google-cloud/kms'
....
2019-12-01T05:26:37.599Z Cloud Functions UpdateFunction us-central1:kms-demo boristep@googlemail.com INVALID_ARGUMENT E  Cloud Functions UpdateFunction us-central1:kms-demo boristep@googlemail.com

有什么想法吗?

【问题讨论】:

    标签: google-cloud-functions google-cloud-kms


    【解决方案1】:

    看起来您实际上并未正确安装该模块。如果您只是按照说明的方式编辑 package.json,那是行不通的。您应该npm install @google-cloud/kms 确保 package.json 正确安装。它将出现在你的 package.json 中名为“依赖项”的块中,新文件将出现在 node_modules 中。

    您可能需要一些时间来了解 npm 如何用于包管理。

    【讨论】:

    • 我说的是云功能。它不是一个 nodejs 应用程序
    • Cloud Functions 实际部署节点应用程序,如果这是您选择的运行时。如果您正在部署 JavaScript,则您正在将其部署到节点容器。安装依赖的方式没有什么不同。
    猜你喜欢
    • 1970-01-01
    • 2014-09-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-04
    • 2016-04-21
    • 2016-12-05
    相关资源
    最近更新 更多