使用Google云端存储库时出现问题

时间:2018-12-29 17:05:42

标签: node.js google-cloud-platform google-cloud-storage google-cloud-sdk

我正在Node.js应用中运行以下代码:

var GoogleCloudStorage = require('@google-cloud/storage');
 var storage =  GoogleCloudStorage({
   projectId: 'PROJECT_ID',
   keyFilename: 'keyfile.json'
 });

显示此错误 GoogleCloudStorage is not a function 怎么了?

1 个答案:

答案 0 :(得分:2)

将代码更改为:

const {Storage} = require('@google-cloud/storage');
const storage =  new Storage({
   projectId: 'PROJECT_ID',
   keyFilename: 'keyfile.json'
 });

我无法让nodejs编译器接受GoogleCloudStorage