Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 6107

Invalid ELF header out of the gate running simple nodejs script

$
0
0

I'm trying to run a simple nodejs script on Ubuntu 14.04, the contents of which are as follows:

http = require('http');http.createServer(function(req, res){  res.writeHead(200, {'Content-Type': 'text/plain' });  res.end('Hello World \n');}).listen(80, '127.0.0.1');

I've installed NodeJs via the instructions found here. Here is the excerpt I followed from that link:

Option 2: Install Node.js with Ubuntu Package Manager

To install Node.js, type the following command in your terminal:

sudo apt-get install nodejs

Then install the Node package manager, npm:

sudo apt-get install npm

Create a symbolic link for node, as many Node.js tools use this name to execute.

sudo ln -s /usr/bin/nodejs /usr/bin/node

I did that, verified that both packages are installed:

enter image description here

But I can't use my .node file without it complaining with this error:

user@host:/var/www/html/nodetest$ node test.nodemodule.js:356  Module._extensions[extension](this, filename);                               ^Error: /var/www/html/nodetest/test.node: invalid ELF header    at Module.load (module.js:356:32)    at Function.Module._load (module.js:312:12)    at Function.Module.runMain (module.js:497:10)    at startup (node.js:119:16)    at node.js:945:3

I've uninstalled and re-installed node as well as npm but it still doesn't work... I'm running Ubuntu 14.04 LTS 64 bit.

Further information:

I decided to build from source and after cloning master from https://github.com/nodejs/node.git and building it then running the same script, this is the error I get:

user@host:/var/www/html/nodetest$ ~/node/node test.nodemodule.js:600  return process.dlopen(module, path._makeLong(filename));                 ^Error: /var/www/html/nodetest/test.node: invalid ELF header    at Object.Module._extensions..node (module.js:600:18)    at Module.load (module.js:490:32)    at tryModuleLoad (module.js:449:12)    at Function.Module._load (module.js:441:3)    at Module.runMain (module.js:607:10)    at run (bootstrap_node.js:414:7)    at startup (bootstrap_node.js:139:9)    at bootstrap_node.js:529:3

It's the same error, obviously, with a different stack trace.

What gives?


Viewing all articles
Browse latest Browse all 6107

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>