A Node.js library that detects whether the current environment is a virtual machine (VM).
It operates as a cross-platform C++ module via the VMAware library.
This can be particularly useful for detecting VM environments in Electron-based applications.
For more detailed information on VM detection, refer to VMAware.
npm i node-vm-detect
Call without any options—this is sufficient for most use cases.
import { getVMInfo } from 'node-vm-detect';
const {
isVM,
brand,
type,
conclusion,
percentage,
detectedCount,
} = await getVMInfo();
These correspond to the setting flags used in VMAware.
Presets
can be selected from DEFAULT
or ALL
(only one must be selected).
Other flags can be specified as an array in the settings
field.
preset: 'DEFAULT' | 'ALL'
settings: ('NO_MEMO' | 'MULTIPLE' | 'HIGH_THRESHOLD' | 'DYNAMIC')[]
These correspond to VMAware’s flag table.
You can selectively exclude or include certain techniques.
techniques: {
only: TechniqueFlags[],
disable: TechniqueFlags[]
}
getVMInfo({
preset: 'ALL',
});
getVMInfo({
settings: ['NO_MEMO', 'HIGH_THRESHOLD'],
});
getVMInfo({
techniques: {
disable: ['VMID'],
},
});
getVMInfo({
techniques: {
only: ['CPU_BRAND'],
},
});
Same result as:
getVMInfo({
techniques: {
only: ['VMID', 'CPU_BRAND'],
disable: ['VMID'],
},
});
Functions to retrieve individual values:
import {
getBrands,
getType,
getConclusion,
getIsVM,
getPercentage,
getDetectedCount,
} from 'node-vm-detect';
Also available via default import:
import nodeVMDetect from 'node-vm-detect';
nodeVMDetect.info();
nodeVMDetect.isVM();
nodeVMDetect.brand();
nodeVMDetect.type();
nodeVMDetect.conclusion();
nodeVMDetect.percentage();
nodeVMDetect.detectedCount();
VMAware supports 32-bit environments, but this library only supports 64-bit platforms.
- Requires Node.js 18 or later (Electron 23 or later).
OS | Arch | Supported |
---|---|---|
Windows | x64 | ✅ |
Windows | x86 | ❌ |
Windows | Arm64 | ✅ |
Windows | Arm32 | ❌ |
MacOS | x64 | ✅ |
MacOS | Arm64 | ✅ |
Linux | x64 | ✅ |
Linux | x86 | ❌ |
Linux | Arm64 | ✅ |
Linux | Arm32 | ❌ |
- Deno support with Deno FFI
- Include other VM detection packages
MIT