Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NodeJS: How to fix different node module version? [duplicate]

Tags:

node.js

I'm trying to start a nodeJS application, but I do get the error

Error: The module '/Users/api/node_modules/bcrypt/lib/binding/bcrypt_lib.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 46. This version of Node.js requires NODE_MODULE_VERSION 57. Please try re-compiling or re-installing the module (for instance, using `npm rebuild` or `npm install`). 

I already run npm install and npm rebuild. But still the same error...

like image 556
user3142695 Avatar asked Aug 18 '17 17:08

user3142695


People also ask

Can we have two different version of node JS in the same system?

As on the same machine, we can only install one version of the nodejs, so it's very painful to uninstall and install the new node version as per your project requirements. To overcome this problem, we can use the Node Version Manager (NVM).

How do I manage different node versions?

Usually, we work on different versions for our Node. js project and it's hard to manage them, but fortunately, there is a tool called NVM(node version manager) which helps to manage your node version and switch between them according to your projects.

Can different versions of the same package be used in the same application?

So you can have multiple versions of the same package running in your app and you can work on the upgrades mitigating possible issues.

Does copying node modules work?

You can always copy node_modules and then run npm install or npm update in the new project to make sure you've got up-to-date versions. npm will use the files in node_modules as a cache and should only bring down newer content if required. In short: it won't hurt.


1 Answers

The bcrypt package needs to be rebuild, because it was initially installed with another version of Node.js.

Try this:

npm rebuild bcrypt --update-binary 

for yarn users:

yarn add bcrypt --force 
like image 195
robertklep Avatar answered Sep 20 '22 11:09

robertklep