Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 节点js Google驱动器api错误_Javascript_Node.js_Google Api_Google Drive Api_Node Modules - Fatal编程技术网

Javascript 节点js Google驱动器api错误

Javascript 节点js Google驱动器api错误,javascript,node.js,google-api,google-drive-api,node-modules,Javascript,Node.js,Google Api,Google Drive Api,Node Modules,我正在尝试使用访问Google Drive API,以便将一些文件上载到我的驱动器帐户,但我遇到了以下错误: drive.files.create({ ^ ReferenceError: drive is not defined at Object.<anonymous> (/Applications/MAMP/htdocs/google_drive/upload.js:16:1) at Module._compile (module.js:643:30)

我正在尝试使用访问Google Drive API,以便将一些文件上载到我的驱动器帐户,但我遇到了以下错误:

drive.files.create({
^

ReferenceError: drive is not defined
    at Object.<anonymous> (/Applications/MAMP/htdocs/google_drive/upload.js:16:1)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Function.Module.runMain (module.js:684:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3

有人能帮助解决这个问题吗?

您需要先定义它

var drive = google.drive("v3");

在谷歌的文档中查找适当的方法:


您需要首先定义它

var drive = google.drive("v3");

在谷歌的文档中查找适当的方法:


我认为你的
constgoogle
声明应该使用一个解构赋值。如:

const {google} = require(googleapis);
然后声明
drive
,如下所示:

const drive = google.drive({version: 'v3',  auth});

其中,
auth
是授权的OAuth2客户端

我认为您的
const google
声明应该使用一个解构赋值。如:

const {google} = require(googleapis);
然后声明
drive
,如下所示:

const drive = google.drive({version: 'v3',  auth});

其中,
auth
是授权的OAuth2客户端

您尚未在代码中定义
驱动器
。一旦你这样做了,它就会工作。你还没有在你的代码中定义
drive
。一旦你这样做了,它就会工作。为什么不定义v3?为什么不定义v3?