How to Compile a Node C++ Addon So That I Can Use Distribute It on Amazon Aws

Cross-compile node module with native bindings with node-gyp

While not really a solution to your problem, a very easy workaround could be to simply compile the native addons on a Linux machine.

For your particular situation, I would use Vagrant. Vagrant can create virtual machines and configure them within seconds.

  1. Find an OS image that resembles Amazon's Linux distro (Fedora, CentOS, others that use yum as package manager - see Wiki)
  2. Use a simple configuration script that, when run by Vagrant on machine startup, will run npm install (optionally it might also remove the node_modules folder before to ensure a clean installation)
  3. For extra comfort, the script can also create the zip file for deployment
  4. Once the installation finishes, the script will shutdown the VM to avoid unnecessary consumption of system resources
  5. Deploy!

It might require some tuning if the linked libraries are not at the same place on the target machine but generally this seems to me like the best and quickest solution.

How to yum install Node.JS on Amazon Linux

Stumbled onto this, was strangely hard to find again later. Putting here for posterity:

sudo yum install nodejs npm --enablerepo=epel

EDIT 3: As of July 2016, EDIT 1 no longer works for nodejs 4 (and EDIT 2 neither). This answer (https://stackoverflow.com/a/35165401/78935) gives a true one-liner.

EDIT 1: If you're looking for nodejs 4, please try the EPEL testing repo:

sudo yum install nodejs --enablerepo=epel-testing

EDIT 2: To upgrade from nodejs 0.12 installed through the EPEL repo using the command above, to nodejs 4 from the EPEL testing repo, please follow these steps:

sudo yum rm nodejs
sudo rm -f /usr/local/bin/node
sudo yum install nodejs --enablerepo=epel-testing

The newer packages put the node binaries in /usr/bin, instead of /usr/local/bin.

And some background:

The option --enablerepo=epel causes yum to search for the packages in the EPEL repository.

EPEL (Extra Packages for Enterprise Linux) is open source and free community based repository project from Fedora team which provides 100% high quality add-on software packages for Linux distribution including RHEL (Red Hat Enterprise Linux), CentOS, and Scientific Linux. Epel project is not a part of RHEL/Cent OS but it is designed for major Linux distributions by providing lots of open source packages like networking, sys admin, programming, monitoring and so on. Most of the epel packages are maintained by Fedora repo.

Via http://www.tecmint.com/how-to-enable-epel-repository-for-rhel-centos-6-5/

Upgrade Kubernetes Cluster using Terraform's provisioner

Finally, I was able to resolve this which means a K8s minor upgrade is successful. Below steps were followed during the course:

  • Deploy a K8s cluster running version 1.11.2
  • Double the node count, change version to 1.11.5 and re-deploy
  • New nodes get created with updated version
  • Remove nodes running old version i.e. 1.11.2
  • Run terraform refresh so as to sync statefile with real world running Infrastructure
  • Change the node count to 3 or half it.
  • Run terraform plan and verify (multiple runs of refresh might be needed)
  • Run terraform apply to apply changes.
  • Statefile should be in sync with remote
  • Run terraform plan which shouldn’t show any resources to be created

I will be trying a major version upgrade shortly and post the results here.

invalid ELF header when using the nodejs ref module on AWS Lambda

This happens when you build on one architecture and then attempt to use the same built addon on a different architecture (or platform in some cases).

According to this page, addons may have to be compiled against an Amazon Linux image on EC2 in order for the compiled addons to be usable on their Lambda service.



Related Topics



Leave a reply



Submit