Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
murmurHash3
✓ const murmurHash3 = require('murmurhash3js');
✗ import murmurHash3 from 'murmurhash3js';
This package primarily supports CommonJS modules in Node.js environments. Direct ES Modules (import/export) are not supported without a bundler configured to handle CJS modules.
murmurHash3.x86.hash32
✓ const hashValue = murmurHash3.x86.hash32('your string');
✗ const hashValue = murmurHash3.hash32('your string');
Hashing functions are nested under `x86` or `x64` namespaces, then by bit length. Accessing them directly from the top-level object will result in an undefined function call.
murmurHash3 (Browser Global)
✓ <script type="text/javascript" src="murmurhash3js.min.js"></script>
<script>
const hash = murmurHash3.x86.hash32("hello");
</script>
When included directly in a browser via a script tag, `murmurHash3` becomes a global object available in the window scope.
This quickstart demonstrates how to use murmurhash3js in a Node.js environment to compute 32-bit and 128-bit hashes with both x86 and x64 algorithms, including the use of an optional seed value.
const murmurHash3 = require('murmurhash3js');
// Hash a string to a 32-bit unsigned integer using x86 algorithm
const data32bit = "I will not buy this record, it is scratched.";
const hash32 = murmurHash3.x86.hash32(data32bit);
console.log(`32-bit hash for "${data32bit}": ${hash32}`); // Example: 2832214938
// Hash a string to a 128-bit hexadecimal string using x86 algorithm
const data128bitX86 = "I will not buy this tobacconist's, it is scratched.";
const hash128X86 = murmurHash3.x86.hash128(data128bitX86);
console.log(`x86 128-bit hash for "${data128bitX86}": "${hash128X86}"`); // Example: "9b5b7ba2ef3f7866889adeaf00f3f98e"
// Hash a string to a 128-bit hexadecimal string using x64 algorithm with a custom seed
const data128bitX64 = "My hovercraft is full of eels.";
const customSeed = 25;
const hash128X64 = murmurHash3.x64.hash128(data128bitX64, customSeed);
console.log(`x64 128-bit hash for "${data128bitX64}" (seed ${customSeed}): "${hash128X64}"`); // Example: "d30654abbd8227e367d73523f0079673"
// The .noConflict() method can be used in browser environments to reassign the global `murmurHash3` variable.
// For Node.js, this method is generally not relevant as 'require' creates a local variable.
Debug
Known issues
breakingThe `murmurhash3js` package has not been updated since April 2015, making it an abandoned project. It lacks modern JavaScript features, module support (like native ESM), and potential performance optimizations or bug fixes that newer implementations might offer. Using unmaintained libraries can pose security risks or compatibility issues with newer environments.fixConsider migrating to actively maintained alternatives like `@cimi/murmurhash3js` (which has its own breaking changes regarding input types, see next warning), `murmurhash3` (by hideo55), or `murmurhash-es` for modern usage, though these might have their own status or caveats.
affects: >=3.0.1
breakingA notable fork, `@cimi/murmurhash3js` (also known as `murmurhash3js-revisited`), introduced a breaking change in its v3.0.0 release. While the original `pid/murmurHash3js` (this package) directly expects string inputs, the `@cimi` fork changed its API to expect an array of bytes (e.g., `Buffer.from(string)` in Node.js or `new TextEncoder().encode(string)` in browsers) instead of strings. Attempting to pass strings directly to the `@cimi` fork will yield incorrect hash values.fixEnsure you are using the correct package and API. If using this `pid/murmurHash3js` package, pass strings directly. If you switched to `@cimi/murmurhash3js`, you MUST convert strings to byte arrays first: `const bytes = Buffer.from(yourString, 'utf8');` in Node.js or `const bytes = new TextEncoder().encode(yourString);` in browsers.
affects: >=3.0.0 (for `@cimi/murmurhash3js`)
gotchaThis package does not natively support ES Modules (`import`/`export` syntax). It is distributed as a CommonJS module and expects to be consumed via `require()` in Node.js environments or as a global variable in browsers.fixFor Node.js, use `const murmurHash3 = require('murmurhash3js');`. For browser, include `<script type="text/javascript" src="murmurhash3js.min.js"></script>`. If you require ESM compatibility, you will need a build step (e.g., Webpack, Rollup, Parcel) to transpile or bundle your code, or use a different MurmurHash3 library that provides native ESM support. affects: >=3.0.1
gotchaWhile community-maintained TypeScript declarations exist via `@types/murmurhash3js`, this package itself does not ship with built-in TypeScript definitions. This means type inference might be limited without installing the `@types` package, and direct usage in a TypeScript project might require manual declaration files or type assertions.fixInstall the DefinitelyTyped package for type support: `npm install --save-dev @types/murmurhash3js`.
affects: >=3.0.1
Errors
Common errors & fixes
ReferenceError: require is not defined
Attempting to use `require()` syntax in an ES Module context (e.g., in a file with `"type": "module"` in `package.json` or imported via `import` in another ESM file) without proper transpilation or bundling.
fixEnsure your project is configured for CommonJS, or use a bundler (like Webpack) that can handle CommonJS modules within an ESM project. Alternatively, switch to a MurmurHash3 library that offers native ES Module support.
TypeError: murmurHash3.x86.hash32 is not a function
Incorrectly attempting to call a hashing function directly on the `murmurHash3` object (e.g., `murmurHash3.hash32`) instead of accessing it via its namespace (`x86` or `x64`).
fixAccess the hashing functions through their correct namespaces: `murmurHash3.x86.hash32()` or `murmurHash3.x64.hash128()`.
Hash values do not match C++ reference implementation or other JS implementations (e.g., different hashes for the same string input)
This specific package (`pid/murmurhash3js`) handles string inputs directly. However, if you are expecting the behavior of a different MurmurHash3 JavaScript library (especially `@cimi/murmurhash3js` or `murmurhash3js-revisited`), which explicitly expects byte array inputs (e.g., `Buffer.from('string')`), passing strings directly will produce different results.
fixVerify which `murmurhash3js` package you have installed and consult its documentation. If you are using `pid/murmurhash3js`, pass strings. If you are using `@cimi/murmurhash3js` or a similar fork that requires byte inputs, ensure you convert your string to a `Buffer` or `Uint8Array` before hashing.
Audit
Dependencies
No dependency data recorded yet.