Skip to content
This repository has been archived by the owner on Jan 15, 2023. It is now read-only.

Node v12: Error when starting #140

Closed
dalisoft opened this issue Jun 4, 2019 · 18 comments
Closed

Node v12: Error when starting #140

dalisoft opened this issue Jun 4, 2019 · 18 comments

Comments

@dalisoft
Copy link
Contributor

dalisoft commented Jun 4, 2019

Hello @mhart.

I got error

error loading shared library ld-linux-x86-64.so.2

when trying to run node.js app (i know it's because of binary), how i can fix this?

FROM mhart/alpine-node:12
RUN apk update && apk upgrade && \
    apk add --no-cache git
WORKDIR /app
COPY app/server.js ./
COPY package.json package-lock.json ./
RUN npm ci --prod

# Only copy over the node pieces we need from the above image
FROM mhart/alpine-node:slim-12
WORKDIR /app
COPY --from=0 /app .
# COPY . .
EXPOSE 3000
CMD ["node", "./app/server.js"]
@mhart
Copy link
Owner

mhart commented Jun 4, 2019

Does this work for you?

docker run --rm mhart/alpine-node:slim-12 node --version

@dalisoft
Copy link
Contributor Author

dalisoft commented Jun 4, 2019

@mhart Yes, result is v12.4.0

@mhart
Copy link
Owner

mhart commented Jun 4, 2019

I think it must be one of your dependencies. What node modules do you depend on?

@dalisoft
Copy link
Contributor Author

dalisoft commented Jun 4, 2019

@mhart
"nanoexpress": "^0.7.5" -> "uWebSockets.js": "uNetworking/uWebSockets.js#binaries".

On my machine with default Node.js v12 installed works good, only inside Docker this issue

@dalisoft
Copy link
Contributor Author

dalisoft commented Jun 4, 2019

@mhart A bit more log

Removing intermediate container fc8290ab9a14
 ---> b9ed890dbe7c
Successfully built b9ed890dbe7c
Successfully tagged backend_docker-multistage-demo-backend:latest
Recreating backend_docker-multistage-demo-backend_1 ... done
Attaching to backend_docker-multistage-demo-backend_1
docker-multistage-demo-backend_1  | /app/node_modules/uWebSockets.js/uws.js:29
docker-multistage-demo-backend_1  |             throw new Error('This version of µWS is not compatible with your Node.js build:\n\n' + e.toString());
docker-multistage-demo-backend_1  |             ^
docker-multistage-demo-backend_1  | 
docker-multistage-demo-backend_1  | Error: This version of µWS is not compatible with your Node.js build:
docker-multistage-demo-backend_1  | 
docker-multistage-demo-backend_1  | Error: Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /app/node_modules/uWebSockets.js/uws_linux_x64_72.node)
docker-multistage-demo-backend_1  |     at /app/node_modules/uWebSockets.js/uws.js:29:9
docker-multistage-demo-backend_1  |     at Object.<anonymous> (/app/node_modules/uWebSockets.js/uws.js:31:3)
docker-multistage-demo-backend_1  |     at Module._compile (internal/modules/cjs/loader.js:774:30)
docker-multistage-demo-backend_1  |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
docker-multistage-demo-backend_1  |     at Module.load (internal/modules/cjs/loader.js:641:32)
docker-multistage-demo-backend_1  |     at Function.Module._load (internal/modules/cjs/loader.js:556:12)
docker-multistage-demo-backend_1  |     at Module.require (internal/modules/cjs/loader.js:681:19)
docker-multistage-demo-backend_1  |     at require (internal/modules/cjs/helpers.js:16:16)
docker-multistage-demo-backend_1  |     at Object.<anonymous> (/app/node_modules/nanoexpress/build/nanoexpress.js:5:27)
docker-multistage-demo-backend_1  |     at Module._compile (internal/modules/cjs/loader.js:774:30)
backend_docker-multistage-demo-backend_1 exited with code 1
dalisoft-MBP:backend dalisoft$ 

@mhart
Copy link
Owner

mhart commented Jun 4, 2019

Yeah, so this is native binary built for glibc Linux – Alpine uses musl instead.

You can try adding apk add --no-cache libc6-compat to your Dockerfile – that will probably fix it. Or you can search for a musl build of uWebSockets

@dalisoft
Copy link
Contributor Author

dalisoft commented Jun 4, 2019

Thanks, i will try and post it here result, this can be marked as FAQ

@mhart
Copy link
Owner

mhart commented Jun 4, 2019

There's a note on the README about musl vs glibc – but I'll add a note about libc6-compat

@dalisoft
Copy link
Contributor Author

dalisoft commented Jun 4, 2019

Thanks, then we can close this issue =)

@mhart
Copy link
Owner

mhart commented Jun 4, 2019

398ec50

@dalisoft
Copy link
Contributor Author

dalisoft commented Jun 4, 2019

I see notes already, now installing deps, thank you for fast reply and fix

@dalisoft dalisoft closed this as completed Jun 4, 2019
@mhart
Copy link
Owner

mhart commented Jun 4, 2019

No probs, hope it all works for you 👍

@dalisoft
Copy link
Contributor Author

dalisoft commented Jun 4, 2019

Ah, it didn't worked and recompiling module also not variant. I think i should use full Linux repo.

@mhart
Copy link
Owner

mhart commented Jun 4, 2019

Looks like the owner of that project only has precompiled binaries, and doesn't allow recompiling?

https://github.com/uNetworking/uWebSockets.js

You could ask them if they could give you a way to compile the addons yourself

@dalisoft
Copy link
Contributor Author

dalisoft commented Jun 4, 2019

Author allows, on my machine i tried recompile, but never succeed before. Looks uWebSockets.js supports ARM binaries, i now trying ARM binary

@mhart
Copy link
Owner

mhart commented Jun 4, 2019

Actually, I think they might be missing the latest binaries for Node v12 from v15.10.0:

https://github.com/uNetworking/uWebSockets.js/tree/v15.10.0

Try installing:

npm install uNetworking/uWebSockets.js#binaries

And then see if that works from there

@mhart
Copy link
Owner

mhart commented Jun 4, 2019

Oh sorry – I just saw you already did that... nevermind!

@dalisoft
Copy link
Contributor Author

dalisoft commented Jun 4, 2019

Thanks for tip, this is my first trying with Docker microservices, so i am not expert, before used Docker only as DB (Redis, Postgres), now decided understand and learn better.
So, i am just getting expierence from these errors and bugs.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants