无法在Windows 10中设置GOOGLE_APPLICATION_CREDENTIALS环境节点js

时间:2018-08-24 06:19:24

标签: javascript node.js loopbackjs google-authentication

我正在使用环回,我想为 GOOGLE_APPLICATION_CREDENTIALS 设置环境变量。这是我设置变量

的方式

enter image description here

稍后,当我运行我的程序并尝试点击url时。我得到了以下例外。

D:\loopback>node .
strong-remoting deprecated Remoting metadata "isStatic" is deprecated. Please specify "prototype.name" in method name instead for isStatic=false. <anonymous>:null:null
Web server listening at: http://localhost:3000
Browse your REST API at http://localhost:3000/explorer
ERROR: Error: The file at "D:\dialogflowservice\service.json" does not exist, or it is not a file. Error: ENOENT: no such file or directory, lstat 'D:\loopback\"D:'
    at GoogleAuth.createError (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:516:16)
    at GoogleAuth.<anonymous> (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:366:32)
    at step (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:47:23)
    at Object.next (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:28:53)
    at D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:22:71
    at new Promise (<anonymous>)
    at __awaiter (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:18:12)
    at GoogleAuth._getApplicationCredentialsFromFilePath (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:348:16)
    at GoogleAuth.<anonymous> (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:291:48)
    at step (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:47:23)
    at Object.next (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:28:53)
    at D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:22:71
    at new Promise (<anonymous>)
    at __awaiter (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:18:12)
    at GoogleAuth._tryGetApplicationCredentialsFromEnvironmentVariable (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:283:16)
    at GoogleAuth.<anonymous> (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:199:55)
(node:948) UnhandledPromiseRejectionWarning: Error: The file at "D:\dialogflowservice\service.json" does not exist, or it is not a file. Error: ENOENT: no such file or directory, lstat 'D:\loopback\"D:'
    at GoogleAuth.createError (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:516:16)
    at GoogleAuth.<anonymous> (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:366:32)
    at step (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:47:23)
    at Object.next (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:28:53)
    at D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:22:71
    at new Promise (<anonymous>)
    at __awaiter (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:18:12)
    at GoogleAuth._getApplicationCredentialsFromFilePath (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:348:16)
    at GoogleAuth.<anonymous> (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:291:48)
    at step (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:47:23)
    at Object.next (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:28:53)
    at D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:22:71
    at new Promise (<anonymous>)
    at __awaiter (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:18:12)
    at GoogleAuth._tryGetApplicationCredentialsFromEnvironmentVariable (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:283:16)
    at GoogleAuth.<anonymous> (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:199:55)
(node:948) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:948) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
ERROR: Error: The file at "D:\dialogflowservice\service.json" does not exist, or it is not a file. Error: ENOENT: no such file or directory, lstat 'D:\loopback\"D:'
    at GoogleAuth.createError (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:516:16)
    at GoogleAuth.<anonymous> (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:366:32)
    at step (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:47:23)
    at Object.next (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:28:53)
    at D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:22:71
    at new Promise (<anonymous>)
    at __awaiter (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:18:12)
    at GoogleAuth._getApplicationCredentialsFromFilePath (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:348:16)
    at GoogleAuth.<anonymous> (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:291:48)
    at step (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:47:23)
    at Object.next (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:28:53)
    at D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:22:71
    at new Promise (<anonymous>)
    at __awaiter (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:18:12)
    at GoogleAuth._tryGetApplicationCredentialsFromEnvironmentVariable (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:283:16)
    at GoogleAuth.<anonymous> (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:199:55)
(node:948) UnhandledPromiseRejectionWarning: Error: The file at "D:\dialogflowservice\service.json" does not exist, or it is not a file. Error: ENOENT: no such file or directory, lstat 'D:\loopback\"D:'
    at GoogleAuth.createError (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:516:16)
    at GoogleAuth.<anonymous> (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:366:32)
    at step (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:47:23)
    at Object.next (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:28:53)
    at D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:22:71
    at new Promise (<anonymous>)
    at __awaiter (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:18:12)
    at GoogleAuth._getApplicationCredentialsFromFilePath (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:348:16)
    at GoogleAuth.<anonymous> (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:291:48)
    at step (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:47:23)
    at Object.next (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:28:53)
    at D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:22:71
    at new Promise (<anonymous>)
    at __awaiter (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:18:12)
    at GoogleAuth._tryGetApplicationCredentialsFromEnvironmentVariable (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:283:16)
    at GoogleAuth.<anonymous> (D:\loopback\node_modules\google-auth-library\build\src\auth\googleauth.js:199:55)
(node:948) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)

特别是如果您看到此错误

  

错误:错误:“ D:\ dialogflowservice \ service.json”文件不存在,或者它不是文件。错误:ENOENT:没有这样的文件或目录,lstat'D:\ loopback \“ D:'

表示该文件不存在或不是文件。我已经检查了多次,文件没有问题。

还有一件事,当我在系统变量中设置相同的google凭据json(通过进入控制面板)时,它工作正常。我在那里做错了什么?

0 个答案:

没有答案