Search code examples
npmbcrypt

How to change my node version on my computer


I updated my node version from 10.16.3 to 12.14.0. 3 months ago, I made api by using node js. At that time, it worked well. But now it throws errors.

These are what I did and errors.

D:\Projects\Project\Mean & Mern\Angular\data\API>node server
internal/modules/cjs/loader.js:1025
return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: The module '\\?\D:\Projects\Project\Mean & Mern\Angular\data\API\node_modules\bcrypt\lib\binding\bcrypt_lib.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 64. This version of Node.js requires
NODE_MODULE_VERSION 72. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1025:18)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Module.require (internal/modules/cjs/loader.js:852:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (D:\Projects\Project\Mean & Mern\Angular\data\API\node_modules\bcrypt\bcrypt.js:6:16)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)

I refer to this url: Node - was compiled against a different Node.js version using NODE_MODULE_VERSION 51

But nothing helps me. Please help me


Solution

  • You can use nvm to select your preferred node version with ease. Check this repo for details: https://github.com/nvm-sh/nvm