1

When I go into node and attempt to require libyaml I get:

> require('libyaml')
Error: /home/ubuntu/shadow/node_modules/libyaml/build/Release/binding.node: invalid ELF header
at Object.Module._extensions..node (module.js:485:11)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (/home/ubuntu/shadow/node_modules/libyaml/index.js:7:15)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)

I'm using node version 0.8.12 and libyaml version 0.2.1. Curiously the error is server dependent, but it doesn't seem to be based on the version numbers, because it runs fine on one of boxes with the same versions.

Ben G
  • 26,091
  • 34
  • 103
  • 170
  • 1
    Guess the module is not installed for the correct machine architecture. Try `npm install libyaml` on the server. – vinayr Aug 22 '13 at 01:00
  • nice, that upgrades it and it works – Ben G Aug 22 '13 at 19:21
  • question -- what if i have multiple architectures, though? npm installs the modules into source control rather than installing from a list on deploy... so if the install was made for one architecture on dev how can you deploy to another on staging or production? – Ben G Aug 22 '13 at 19:26

2 Answers2

2

One can also use 'npm rebuild module-name' to recompile the C code on the deployment machine as part of preinstall script.

Documentation

1

Thanks vinayr for advising me to run npm install on the production box. The issue is that they needed to install npm differently. I resolved that with a pre-deploy command on the box as part of the deploy. Problem solved.

Ben G
  • 26,091
  • 34
  • 103
  • 170