The EBADPLATFORM error occurs when a package doesn't support your operating system or CPU architecture. This is common with native binaries that aren't built for all platforms.
Fixes npm ERR! code EBADPLATFORM
npm view package-name os
npm view package-name cpu
# Your platform
node -p "process.platform + ' ' + process.arch"npm view package-name osnpm view package-name cpu# Your platformnode -p "process.platform + ' ' + process.arch"npm ERR! code EBADPLATFORM
On this page
Packages can specify which operating systems (os) and CPU architectures (cpu) they support. EBADPLATFORM means your current platform isn't in the supported list. This commonly occurs with packages containing native binaries (compiled C/C++ code), platform-specific tools, or packages intentionally limited to certain platforms.
View package platform support:
npm view package-name os
npm view package-name cpu
# Your platform
node -p "process.platform + ' ' + process.arch"Make the dependency optional:
{
"optionalDependencies": {
"platform-specific-pkg": "^1.0.0"
}
}npm won't fail if optional deps can't install.
Skip native compilation:
npm install --ignore-scriptsNote: Package may not work without its native parts.
Search for alternatives:
# Search for similar functionality
npm search "functionality you need"
# Check if pure JS version existsHandle platform differences:
{
"scripts": {
"postinstall": "node scripts/platform-setup.js"
},
"optionalDependencies": {
"win-specific": "^1.0.0",
"mac-specific": "^1.0.0"
}
}On Apple Silicon:
# Check architecture
uname -m
# Run terminal in Rosetta
arch -x86_64 npm installFor cross-platform development, consider abstracting platform-specific code behind a common interface. Docker can provide consistent Linux environment regardless of host. Some native packages offer prebuilt binaries for multiple platforms - check documentation. In monorepos, platform-specific packages may need workspace configuration.