Programing

노드-NODE_MODULE_VERSION 51을 사용하여 다른 Node.js 버전에 대해 컴파일되었습니다.

crosscheck 2020. 9. 5. 08:59
반응형

노드-NODE_MODULE_VERSION 51을 사용하여 다른 Node.js 버전에 대해 컴파일되었습니다.


터미널에서 노드 응용 프로그램을 실행하고 있습니다. 최근에 노드 v8.5.0으로 업그레이드했지만 다음 오류가 발생합니다.

Error: The module '/tidee/tidee-au/packages/tidee-au-server/node_modules/bcrypt/lib/binding/bcrypt_lib.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 51. 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`).
    at Object.Module._extensions..node (module.js:653:18)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/tidee/tidee-au/packages/tidee-au-server/node_modules/bcrypt/bcrypt.js:6:16)
    at Module._compile (module.js:624:30)
    at Module._extensions..js (module.js:635:10)
    at Object.require.extensions.(anonymous function) [as .js] (/tidee/tidee-au/packages/tidee-au-server/node_modules/babel-register/lib/node.js:152:7)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/tidee/tidee-au/packages/tidee-au-server/server/helpers/encryptPass.js:1:16)

이 문제를 해결하는 방법을 아십니까?


폴더에서 모듈 폴더 ( bcrypt) 를 제거 node_modules하고 다시 설치해야합니다. 다음 명령을 사용하십시오.

$ rm -rf node_modules/bcrypt
$ npm install
// or
$ yarn

당신은해야 할 패키지를 다시 하고 너무 바이너리의 업데이트 할 NPM에게 . 시험:

npm rebuild bcrypt --update-binary

@robertklep,이 명령을 사용하여 상대의 질문에 대답 .

재 구축만으로 문제가 해결되지 않았습니다. 이것은 내 응용 프로그램에서 잘 작동합니다.

도움이 되었기를 바랍니다.


나는 똑같은 문제가 있었고 여기에 언급 된 것은 나를 위해 일 하지 않았습니다 . 나를 위해 일한 것은 다음과 같습니다.

  1. main.js전자에 의해 실행되는 파일에 필요한 모든 종속성이 필요합니다 . (이것은 나에게 첫 번째 중요한 부분 인 것 같았다)
  2. 실행 npm i -D electron-rebuild하여 electron-rebuild 패키지 추가
  3. node-modules폴더와 packages-lock.json파일을 제거하십시오 .
  4. npm i모든 모듈을 설치하려면 실행하십시오 .
  5. ./node_modules/.bin/electron-rebuild모든 것을 재건하기 위해 실행

그렇지 않으면 내 Mac에서 작동하지 않은 후에 직접 실행하는 것이 매우 중요 합니다 ../node_modules/.bin/electron-rebuildnpm i

좌절 한 영혼을 도울 수 있기를 바랍니다.


간단히 실행 :

npm uninstall bcrypt

뒤에 :

npm install bcrypt(또는 bcryptpackage.json 파일 에서 종속성으로 선언 된 npm install경우 )


Most likely you have this issue due to the package-lock.json. Somehow it seems to block you from recompiling or rebuilding your dependencies, even if you explicitly run npm rebuild. I ran all the following to fix it for me:

rm package-lock.json;
rm -rf node_modules;
npm install;

you can see this link

to check your node verison right. using NODE_MODULE_VERSION 51 means that your node version is nodejs v7.x, requires NODE_MODULE_VERSION 57 means you need upgrade your node to v8.x,so you need to upgrade your node. and then you need run npm rebuild command to rebuild your project


npm rebuild bcrypt --update-binary

I've the same promble but different package, i run this code and deal with it


Be sure you only have one version of NodeJS installed. Try these two:

node --version
sudo node --version

I initially installed NodeJS from source, but it was the incorrect version and 'upgraded' to the newest version using nvm, which doesn't remove any previous versions, and only installs the desired version in the /root/.nvm/versions/... directory. So sudo node was still pointing to the previous version, whilst node was pointing to the newer version.


I got the same error but I was trying to run a node application using a Docker container.

I fixed it by adding a .dockerignore file to ignore the node_modules directory to make sure that when the docker image builds, it builds the native packages for the image I wanted (Alpine) instead of copying over the node_modules compiled for my host (Debian).


Turns out my problem was user-error: make sure the version of node you are using for running is the same that you are using when running an npm install or yarn.

I use NVM for versioning node and was running yarn via a terminal, but my IDE was set to use an older version of node when running and it was throwing the error above. Matching my IDE's version of node in the run config to node --version fixed the issue.


I got this error when running my app with systemd:

ExecStart=/usr/local/bin/node /srv/myapp/server.js

But I was using a different version for npm install in the shell:

$ which node
/home/keith/.nvm/versions/node/v8.9.0/bin/node

If this is your setup, you can either hardcode the node version in the service file or follow a workaround like this one.


After trying different things. This worked.

Delete your node modules folder and run

npm i

I faced the same issue with grpc module and in my case, I was using electron and have set a wrong electron version in the env variable "export npm_config_target=1.2.3", setting it to the electron version I am using resolved the issue on my end. Hope this helps someone who set env variables as given here (https://electronjs.org/docs/tutorial/using-native-node-modules#the-npm-way)


You could remove bcrypt entirely and install bcryptjs. It is ~30% slower, but has no dependencies, so no pains installing it.

npm i -S bcryptjs && npm uninstall -S bcrypt

We've installed it successfully for our applications. We had issues with bcrypt not compiling on AWS instances for Node v8.x


Potentially, inconsistency of the node JS versions is what causes the problem. As stated in the documentation. Be sure to use one of the lts release. E.g. specify this in your Dockerfile:

# Pull lts from docker registry
FROM node:8.12.0

# ...

Check the Node version you're using, might be a mismatch between what it is expected.


I had the same problem and none of these solutions worked and I don't know why, they worked for me in the past for similar problems.

Anyway to solve the problem I've just manually rebuild the package using node-pre-gyp

cd node_modules/bcrypt
node-pre-gyp rebuild

And everything worked as expected.

Hope this helps


I just got this error running kadence the installed "kadence" script checks for nodejs first and only runs node if there is no nodejs. I have the latest version of node linked into my ~/bin directory but nodejs runs an older version that I had forgotten to uninstall but never caused problems until just now.

So people with this problem might check if node and nodejs actually run the same version of node...


In my case, I was in my office proxy which was skipping some of the packages. When I came out of my office proxy and tried to do npm install it worked. Maybe this helps for someone.

But it took me several hours to identify that was the reason.


In my case I was running nodejs instead of node. Due to nodejs being installed by the package manager:

# which node
/home/user/.nvm/versions/node/v11.6.0/bin/node

# which nodejs
/usr/bin/nodejs

I had a similar problem with robotjs. There were some deprecated code that required node v11, but I had already compiled electron code on v12. So I got basically the same error. Nothing here worked as I was basically trying to rebuild electron and my other dependencies into node v11 from v12.

Here is what I did (part of this is based on chitzui's answer, credit where credit is due):

  • Back up package.json
  • completely delete the node_modules folder
  • completely delete package_lock.json
  • delete package.json (will reinit later)
  • Close any open editors and other cmd windows that are in the project's directory.
  • run npm init to reinit package, then missing data with old backed up package.json
  • run npm i
  • fixed :)

Hope this helps.


None of them worked for me but this:

npm install 
npm start

run npm config set python python2.7 and run npm install again the party is on.

참고URL : https://stackoverflow.com/questions/46384591/node-was-compiled-against-a-different-node-js-version-using-node-module-versio

반응형