谷歌云函数响应消息的数字签名



我尝试使用Google Cloud KMS对响应消息进行签名。

但立即出现错误。

索引.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"
}

.log:

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

知道吗?

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

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

最新更新