Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Cannot find module 'thrift/transport' #3

Open
peking2 opened this issue Sep 8, 2013 · 19 comments
Open

Error: Cannot find module 'thrift/transport' #3

peking2 opened this issue Sep 8, 2013 · 19 comments

Comments

@peking2
Copy link

peking2 commented Sep 8, 2013

Hello

I'm encountering this problem. At the beginning, it complained thrift was missing. Once I installed thrift, it complains that thrift/transport is missing. What modules should I install to resolve it?

at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/home/gzhao/test/node_modules/node-hive/node-hive.js:2:18)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (/packages/installed/display_activity_processor-HEAD/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:211:36)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/home/gzhao/test/test.coffee:1:8, :4:10)
at Object. (/home/gzhao/test/test.coffee:1:1, :14:4)
at Module._compile (module.js:456:26)

Thanks.

@doxav
Copy link

doxav commented Feb 17, 2014

I assume you followed the tutorial. You don't need to require thrift transport. The code below worked for me:
var thrift = require('thrift');
transport = thrift.TBufferedTransport();
protocol = thrift.TBinaryProtocol();

@typeofgraphic
Copy link

I am also having the same issue - 'Error: Cannot find module 'thrift/transport'

@doxav
Copy link

doxav commented Feb 21, 2014

As I suggested previously, have you tried "not to require thrift/transport" but to use this code instead:
var thrift = require('thrift');
transport = thrift.TBufferedTransport();
protocol = thrift.TBinaryProtocol();

@typeofgraphic
Copy link

I was never trying to include thrift/transport, or thrift at first - only node-hive. I want to query some data on Hive (someone else set this up, clearly I am new to Hive here).

After running npm install node-hive the console throws an error that thrift is missing... npm install thrift.. - 'Error: Cannot find module 'thrift/transport'

To answer your question, yes I used the above code and it didn't solve my issue. I am putting the code in the var .. require(stuff) section of app.js.

@doxav
Copy link

doxav commented Feb 21, 2014

I just remember that I first confused between npm install node-thrift and
npm install thrift, then I had to change includes in my code as per the
code suggested before. No clue if Hive may have the same kind of problem.

On Fri, Feb 21, 2014 at 4:48 PM, PB [email protected] wrote:

I was never trying to include thrift/transport, or thrift at first - only
node-hive. I want to query some data on Hive (someone else set this up,
clearly I am new to Hive here).

After running npm install node-hive the console throws an error that
thrift is missing... npm install thrift.. - 'Error: Cannot find module
'thrift/transport'


Reply to this email directly or view it on GitHubhttps://github.com//issues/3#issuecomment-35742394
.

@lethalbrains
Copy link

👍 @doxav

@nikhil32
Copy link

Hi @doxav , I tried and getting same issue require thrift/transport.
Is there any update for this issue. If so please let me know.

@vardancse
Copy link

Any update guys?

@daumann
Copy link

daumann commented Jun 20, 2016

Put your thrift dependency to 0.9.1, that should fix the issue.

@cmorrow
Copy link

cmorrow commented Jul 19, 2016

@daumann changing the Thrift dependency to "0.9.1" does not fix the problem for me.

@daumann
Copy link

daumann commented Jul 20, 2016

@cmorrow indeed that was the issue for the repo node-thrift-hive, in which the example requires transport at "thrift/lib/thrift/transport" but has the dependency of Thrift on latest. There depending on 0.9.1 fixes the issue there.

In this case, notice that the package.json does not have any dependencies but the node_modules are "hardcoded". So when running node-hive.js it depends on this specific folder structure inside node_modules. If you use a global Thrift installation it will fail, as well as if you add thrift to the dependencies and do npm install - because the folder structure is different.

@AjeetSahu
Copy link

I am using thrift-hive. i am getting following error

Cannot find module 'thrift/lib/thrift/transport'

Error: Cannot find module 'thrift/lib/thrift/transport'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object. (/home/hduser/rproj/testproj1/node_modules/thrift-hive/lib/hive.js:12:13)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
I have tried changing the Thrift dependency to "0.9.1" and added
var thrift = require('thrift');
transport = thrift.TBufferedTransport();
protocol = thrift.TBinaryProtocol();
to hive.js but these did not work for me. Please help.

@daumann
Copy link

daumann commented Aug 1, 2016

@AjeetSahu

  • leave hive.js as it is
  • change thrift dependency in package.json to "thrift": "0.9.1"
  • (if you did execute npm install before, remove node_modules folder)
  • npm install

or if you like to keep Thrift on latest:

@AjeetSahu
Copy link

Hi Daumann
Thanks for your help. I have got rid of that error....But now i am getting following error

events.js:141
throw er; // Unhandled 'error' event
^

Error: connect ECONNREFUSED 127.0.0.1:10000
at Object.exports._errnoException (util.js:873:11)
at exports._exceptionWithHostPort (util.js:896:20)
at TCPConnectWrap.afterConnect as oncomplete

npm ERR! Linux 3.19.0-64-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "start"
npm ERR! node v4.4.7
npm ERR! npm v2.15.8
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: node ./bin/www
npm ERR! Exit status 1
npm ERR!

Could you please guide me how to resolve this error.

@ruchit31
Copy link

ruchit31 commented Aug 1, 2016

@daumann
//hive query and console.log is not working
var client = hive.createClient({
version: '0.7.1-cdh3u2',
server: '127.0.0.1',
port: 10000,
timeout: 1000
});
// Execute call
client.execute('use default', function(err){
// Query call
console.log("ruchill");
client.query('show tables')
.on('row', function(database){
console.log(database+"ruchi");
})
.on('error', function(err){
console.log(err.message);
client.end();
})
.on('end', function(){
client.end();
});
});

@ruchit31
Copy link

ruchit31 commented Aug 3, 2016

Hi @daumann Thanks for making this node module and making it available to us, can you please look into this error, I am stuck in this from past 2 days . Thank you so much :)

@hardikphp
Copy link

Please follow two step to fix the issue in Node.js
As per @doxav given code, put that code on thrift-hive/lib/hive.js

transport = require('thrift/lib/thrift/transport');

Replace code with

thrift = require('thrift');
transport = thrift.TBufferedTransport();
protocol = thrift.TBinaryProtocol();


@Leo555
Copy link

Leo555 commented Nov 1, 2016

I changed "transport = thrift.TBufferedTransport()", but got "Cannot read property 'TBufferedTransport' of undefined"

@hardikphp
Copy link

@Leo555 yes, it will not work as new version hive does not support it, try http://stackoverflow.com/questions/38670740/error-in-connecting-node-js-application-to-hive/39529926#39529926

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests