Run Node on Linux on OS X, seamlessly.
OS X Yosemite or higher (for xhyve hypervisor).
npm install nodux -g
Nodux has the exact same functionality as node:
nodux [node|v8 flags] <file> [args...]
This will run node in a small VM running Tiny Core Linux.
All node flags are supported (apart from
--r - coming soon).
Just like node, if no file is supplied,
nodux will open a REPL.
noduxwill run in the same VM
nodux-adm killcan be used to stop the VM
process.envrefers to host machine environment variables
xhyve binary (included) needs root permissions to
access the OS X network layer. On the first run
will ask for a password, these are the steps it performs
setuidbit, which runs xhyve as root without needing sudo)
$ nodux-admUsage: nodux-adm <command> [args...]Commands:Commands:boot boots the vmstatus checks if vm is running or notnpm [args] run npm commands inside the vm, on host cwd (useful for npm rebuild)ssh sshes into vm and attaches the session to your terminalip get the ip of the vmrun runs a single command over sshhalt [-f] runs sudo halt in vm, initiating a graceful shutdown. The -f flagimmediately ungracefully kills the vm process with SIGKILLpid get the pid of the vm processkill run the kill command against a process in the vmps run ps command within vmvms print all vm processes running on this machinebin output contents of node binary within vm (useful for core dump analysis)
Node is running in a Linux environment from an OS X file system.
This means any installed modules with native bindings will fail inside the VM. Any native bindings need to be recompiled within the VM - this is on the road map.
Additionally, the node process that runs in the VM is chrooted to the root of the host system. This means that exec/spawning any common Linux/OS X binary in hosts PATH will fail. Node will attempt to execute the OS X binary on Linux. This is also on the roadmap to solve.
tl;dr - if you want a core file, use the
Inside the VM, Nodux mounts the host file system, and then chroots into it just before executing code - this makes for an apparently seamless environment: we execute on a linux machine, but seemingly on the OS X file system.
However, generating a core file in this context fails. When process abort occurs the underlying C code attempts apply file meta data to the core file that's incompatible with the mounted host file system, so the core file is written but empty. The solution to this is to write the core file to a path on the VM filesystem, however since we're in a chroot that can't be done.
To work around this we supply the
nodux --kludge-jail thing-that-creates-core-dump.js