Kelvin
Kelvin

Reputation: 2288

error when i run nodejs on EC2

After I git clone my app onto EC2 and run it with the following command:

nohup nodejs app.js &

I get the following error:

[Error: /home/ubuntu/bluesky-scheduler2/node_modules/agenda/node_modules/mongodb/node_modules/bson/build/Release/bson.node: invalid ELF header]
js-bson: Failed to load c++ bson extension, using pure JS version
[Error: /home/ubuntu/bluesky-scheduler2/node_modules/mongodb/node_modules/bson/build/Release/bson.node: invalid ELF header]
js-bson: Failed to load c++ bson extension, using pure JS version

Any ideas how can I fix this?

Upvotes: 1

Views: 1941

Answers (2)

steampowered
steampowered

Reputation: 12062

This happened to me when I inadvertently committed the node_modules/mongodb folder in git after developing on a windows box. Most node modules will be generic javascript an run on either windows or linux, however mongodb has binary files specific to the operating system in the node_modules/mongodb folder. Deploying the code to linux pushes a windows binary to linux, hence the error.

The solution is to remove the nodemodules/mongodb directory on the linux server, then run npm install to install mongodb dependancies from the linux environment.

Upvotes: 0

ssemilla
ssemilla

Reputation: 3970

I had the same issue. The invalid ELF header implies a binary that is not loadable or executable by the system. So I tried to build bson.

go to the root directory of the bson module. e.g. in my case: mongodb/node_modules/bson and then execute make

tldr;

$ cd /home/ubuntu/bluesky-scheduler2/node_modules/agenda/node_modules/mongodb/node_modules/bson/
$ make

Upvotes: 1

Related Questions