Mismatching NODE_MODULE_VERSION when using publicKeyFromSecretKey
Problem
When trying to call publicKeyFromSecretKey
there is an error being thrown regarding a mismatching NODE_MODULE_VERSION. Is there a way to get this to work without having to switch my node version?
Code
index.ts
import { getSecretKey, publicKeyFromSecretKey } from "@neon-exchange/nash-protocol";
const run = async () => {
const secretKey = getSecretKey();
try {
const publicKey = await publicKeyFromSecretKey({
secret: secretKey.toString(),
curve: "Secp256k1"
});
} catch (e) {
console.error(e);
}
}
run();
package.json
{
"name": "nash",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start:dev": "nodemon",
"build": "rimraf ./build && tsc",
"start": "npm run build && node build/index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@types/node": "^13.9.8",
"nodemon": "^2.0.2",
"rimraf": "^3.0.2",
"ts-node": "^8.8.1",
"typescript": "^3.8.3"
},
"dependencies": {
"@cityofzion/neon-js": "^4.7.2",
"@neon-exchange/nash-protocol": "^3.2.7"
}
}
The Error
Error: The module '.../nash/node_modules/@neon-exchange/nash-protocol/build/main/native/index_osx.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 64. This version of Node.js requires NODE_MODULE_VERSION 79. Please try re-compiling or re-installing the module (for instance, using
npm rebuild
ornpm install
). at Object.Module._extensions..node (internal/modules/cjs/loader.js:1173:18) at Module.load (internal/modules/cjs/loader.js:972:32) at Function.Module._load (internal/modules/cjs/loader.js:872:14) at Module.require (internal/modules/cjs/loader.js:1012:19) at require (internal/modules/cjs/helpers.js:72:18) at loadNodeFile (.../nash/node_modules/@neon-exchange/nash-protocol/src/native/index.ts:26:14) at Object. (.../nash/node_modules/@neon-exchange/nash-protocol/src/native/index.ts:33:19) at Module._compile (internal/modules/cjs/loader.js:1123:30) at Module._extensions..js (internal/modules/cjs/loader.js:1143:10) at Object.require.extensions. [as .js] (.../nash/node_modules/ts-node/src/index.ts:832:44)