개발

bcrypt invalid ELF header 에러 해결하기

배우겠습니다 2024. 2. 14. 23:16

환경

docker

nest

mac os

 

문제상황

bcrypt가 안돼요

 

해결하기

1. .dockerignore에 node_modules 설정

안된다.

 

2. docker compose volume에 /node_modules설정

도커쪽에서 오류가 난다. 조금 더 손보면 될 것 같은데 편안 해결방법을 더 찾아보자.

 

해결

https://www.npmjs.com/package/bcryptjs

 

bcryptjs

Optimized bcrypt in plain JavaScript with zero dependencies. Compatible to 'bcrypt'.. Latest version: 2.4.3, last published: 7 years ago. Start using bcryptjs in your project by running `npm i bcryptjs`. There are 3441 other projects in the npm registry us

www.npmjs.com

이걸쓰는게 제일 간단한 해결법이었다.

 

이유

I've found that bcrypt compiled on OSX will not quite work on Linux. In other words, if you check in the bcrypt compiled on your local OSX workstation, and try to run the node app on your linux servers, you will see the error above.

Only problem is: bcrypt, unlike other node modules, only installs a single OS binary. So committing a Linux-installed bcrypt will break your Mac developer systems,

It is not cross-compiling, rather giving you pre-compiled binaries. Node-gyp does NOT cross-compile by default. 

 

해당 모듈은 크로스컴파일을 하지 않고 미리 컴파일된 바이너리를 제공하지 않아 OS가 맞지 않으면 오류가 난다고한다.