0

I'm trying to updated (fool me) a node project built with nuxt and prepare a DockerFile and respective docker compose for it.

The build runs fine, but when execute docker-compose up this is the error:

e_nuxt-web-1  | Error: Missing binding /app/node_modules/node-sass/vendor/linux-x64-72/binding.node
e_nuxt-web-1  | Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 12.x
e_nuxt-web-1  | 
e_nuxt-web-1  | Found bindings for the following environments:
e_nuxt-web-1  |   - OS X 64-bit with Unsupported runtime (102)
e_nuxt-web-1  |   - OS X 64-bit with Node.js 12.x

This is the DockerFile:

FROM node:12.18.0

WORKDIR /app

COPY . .

RUN apt-get update || : && apt-get install -y \
    python \
    build-essential

RUN npm install

RUN npm install typescript

RUN npm rebuild node-sass --force

ENV HOST 0.0.0.0
EXPOSE 3000

CMD [ "npm", "run", "dev" ]

dockercompose.yml

version: "3.4"

services:

  web:
    build: .
    ports:
      - "3000:3000"
    volumes:
      - .:/app

As you see I'm installing some missing parts to the node image (is there a better starting image for node projects?) and then trying to rebuild node-sass because this finding: Node Sass does not yet support your current environment: Windows 64-bit with Unsupported runtime (88)

But as you see the error says the binding was built with "OS X", where the running container is Linux. Apparently this rebuild --force doesn't do what I expect, how should I force to rebuild the library for the proper OS?

Updating nuxt is a nightmare so I'd like to recreate the expected running environment for that version of nuxt which uses node-sass ^4.14.1 (which works with node12). While delving a bit more I see some suggestions about deleting the node-sass folder inside node-modules, why would that even make a difference?

T. Rossi
  • 465
  • 1
  • 6
  • 23
  • 1
    How are you running the container; what's in the `docker-compose.yml` file? Are there `volumes:` that replace the image's `/app` directory with host content, and if so, does deleting that block help? – David Maze Mar 25 '22 at 18:18
  • I've added the dockercompose.. oh now I see it, am I replacing the content of the whole directory with my local one? Should I add the node-modules to dockerignore? I'll try right away! – T. Rossi Mar 25 '22 at 18:22

1 Answers1

0

You are mounting your project directory (with all files either hidden or not) to the service container.

This configuration basically benefits if you are trying to have your changes reflected in realtime to your container while I doubt you are looking for this based on your installation description.

You should omit the volumes key in your docker-compose.yml file:

version: "3.4"

services:

  web:
    build: .
    ports:
      - "3000:3000"

You should instruct docker to ignore your host node_modules directory as well. Add the directory name into your dockerignore config file (living in top of your project directory):

# other ignored files
node_modules
tmarwen
  • 15,750
  • 5
  • 43
  • 62
  • thanks for sharing, actually I'm building this to test and develop so yes I'd need to see changes. Apparently it's now impossible to build that version of nuxt on OS X, so I thought I could use a docker.. not so easy as well for now. – T. Rossi Mar 25 '22 at 22:53
  • This approach is error prone and I would recommend not mapping build dependencies to target container whatever the technology stack is. – tmarwen Mar 26 '22 at 11:18