This is exactly what the npm rebuild command does. Just run npm rebuild inside your application directory after copying it to a new virtual machine and any binary add-ons will be recompiled according to the current processor architecture and version of node. If the initial npm install before the copy was fully successful, npm rebuild on the second virtual machine does not need to load anything. Just make sure that the second virtual machine has a reasonably close version of node and the corresponding compilers, libraries, etc. (Build-essential and python on debian, for example).
source share