uNetworking / uWebSockets.js

μWebSockets for Node.js back-ends :metal:
Apache License 2.0
7.65k stars 560 forks source link

Installing in a Ubuntu docker image #980

Closed vulkanosaure closed 8 months ago

vulkanosaure commented 8 months ago

Hi,

I'm trying to install uWebSockets.js on a vanilla Ubuntu docker image, in which I installed node When running the container, I get the error

_Error: Cannot find module 'uWebSockets.js'

Require stack:

- /var/www/socket/main.js

    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)

    at Module._load (node:internal/modules/cjs/loader:922:27)

    at Module.require (node:internal/modules/cjs/loader:1143:19)

    at require (node:internal/modules/cjs/helpers:119:18)

    at Object.<anonymous> (/var/www/socket/main.js:1:1)

    at Module._compile (node:internal/modules/cjs/loader:1256:14)

    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)

    at Module.load (node:internal/modules/cjs/loader:1119:32)

    at Module._load (node:internal/modules/cjs/loader:960:12)

    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12) {

  code: 'MODULE_NOT_FOUND',

  requireStack: [ '/var/www/socket/main.js' ]

}_

Here's my dockerfile

FROM ubuntu

WORKDIR /var/www/socket

#install node
RUN apt-get update
RUN apt-get install -y ca-certificates curl gnupg
RUN mkdir -p /etc/apt/keyrings
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
RUN apt-get update
RUN apt-get install nodejs -y

#install curl + bun
RUN apt upgrade
RUN apt install curl
RUN apt install unzip
RUN curl -fsSL https://bun.sh/install | bash

#install uWebSockets
RUN ~/.bun/bin/bun install uNetworking/uWebSockets.js#v20.33.0

CMD ["node","main.js"]

During the creation process, i can see the message installed uWebSockets.js@github:uNetworking/uWebSockets.js#c10b47c Which seems to say that uWebSockets has been correctly installed

I'd went to the node_modules folder to confirm if the uWebSockets.js folder is there, The command which node returns /usr/bin/node and cd /usr/bin/node returns can't cd to /usr/bin/node as if it's a problem of access right

The content of main.js is the same as the example in the readme.

Any idea of how to troubleshoot this ? Thanks in advance.