Node BigQuery包 - Ubuntu上的ENOENT错误

时间:2021-09-30 13:52:10

I am trying to use the BigQuery package found here: https://www.npmjs.org/package/bigquery

我试图使用这里找到的BigQuery包:https://www.npmjs.org/package/bigquery

Setup: Ubuntu 14, latest Node, nginx, plus that bigquery package and its dependencies.

设置:Ubuntu 14,最新的Node,nginx,以及bigquery包及其依赖项。

I believe I've set it up correctly, including the PEM files, but I am getting an error from gauth when I try to load the key files:

我相信我已经正确设置了它,包括PEM文件,但是当我尝试加载密钥文件时,我收到了来自gauth的错误:

[2014-05-04 02:14:57.008] [ERROR] gauth - { [Error: ENOENT, open './key.mydomain.com.p12.pem']
  errno: 34,
  code: 'ENOENT',
  path: './key.mydomain.com.p12.pem' }
Error: ENOENT, open './key.mydomain.com.p12.pem'

I am running just a simple test script that looks like so (I've Xxxx'd out my project ID):

我正在运行一个看起来像这样的简单测试脚本(我已经Xxxx了我的项目ID):

var http = require('http')
  , bq = require('bigquery')
  , fs = require('fs')
  , prjId = 'xxxxxxxxxx'; //you need to modify this

bq.init({
    scope: 'https://www.googleapis.com/auth/bigquery',
    client_secret: './client_secrets.json',
    privatekey_pem: './private.mydomain.com.p12.pem',
    key_pem: './key.mydomain.com.p12.pem'
  });


http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.write('Testing BigQuery... \n');

    bq.job.query(prjId, 'select count(*) from publicdata:samples.wikipedia', function(e,r,d){
      if(e) console.log(e);
      console.log( JSON.stringify(d) );
    });

    res.end('Done. \n');
}).listen(3000, "127.0.0.1");
console.log('Server running at http://127.0.0.1:3000/');

I've tried referencing the file different, using __dirname and also no slashes.

我尝试使用__dirname并且没有斜杠来引用不同的文件。

Any thoughts? I'm looking at the Google code in the dependencies, too, but just not figuring this one out.

有什么想法吗?我也在查看依赖项中的Google代码,但只是没有想出这个。

2 个解决方案

#1


1  

A 34 error means 'no such file or directory'. Are you sure the file key.mydomain.com.p12.pem exists in the same directory as your index file?

34错误意味着'没有这样的文件或目录'。您确定文件key.mydomain.com.p12.pem与索引文件存在于同一目录中吗?

#2


1  

Ah, figured it out: the P12 file I used to generate the private and public keys was mismatched with my client_secrets.

啊,想通了:我用来生成私钥和公钥的P12文件与我的client_secrets不匹配。

So, if anyone else gets this issue, the ENOENT could be caused by have a client_secrets.json and a set of keys for a service account that were not created together.

因此,如果其他人遇到此问题,ENOENT可能是由于client_secrets.json和一组未一起创建的服务帐户的密钥引起的。

#1


1  

A 34 error means 'no such file or directory'. Are you sure the file key.mydomain.com.p12.pem exists in the same directory as your index file?

34错误意味着'没有这样的文件或目录'。您确定文件key.mydomain.com.p12.pem与索引文件存在于同一目录中吗?

#2


1  

Ah, figured it out: the P12 file I used to generate the private and public keys was mismatched with my client_secrets.

啊,想通了:我用来生成私钥和公钥的P12文件与我的client_secrets不匹配。

So, if anyone else gets this issue, the ENOENT could be caused by have a client_secrets.json and a set of keys for a service account that were not created together.

因此,如果其他人遇到此问题,ENOENT可能是由于client_secrets.json和一组未一起创建的服务帐户的密钥引起的。