Node-Sass Errors Occurring During Docker Compose Up Build

Every time I attempt to construct my docker container using the docker-compose up --build command, a multitude of errors surfaces. The reoccurring issues with node-sass and node-gyp persist despite exhaustive searches for solutions.

System Specs

  • MacOS 11.2.3 (MacBook Pro M1)
  • Node 15.0.0
  • Docker 3.3.1

Command Executed

  • docker-compose up --build

Dockerfile Configuration

FROM node

# Establish client setup
WORKDIR /usr/src/app/client
COPY ./client/package*.json ./
RUN npm install

COPY ./client/src ./src
COPY ./client/tsconfig.json ./tsconfig.json
COPY ./client/babel.config.js ./babel.config.js
COPY ./client/.eslintrc.json ./.eslintrc.json

RUN npm run build

# Set up server
WORKDIR /usr/src/app/server
COPY ./server/package*.json ./
RUN npm install

COPY ./server/src ./src
COPY ./server/database ./database
COPY ./server/tests ./tests
COPY ./server/tsconfig.json ./tsconfig.json
COPY ./server/knexfile.ts ./knexfile.ts

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

Details from docker-compose.yml

version: "3.9"
services:
  app:
    build: .
    ports:
      - "3000:3000"
      - "9229:9229"
    environment:
      NODE_ENV: development
      SESSION_SECRET: a_secret
      REDIS_SECRET: a_secret
      JWT_SECRET: a_secret
      DB_USER: a_user
      DB_PASSWORD: a_password
      DB_NAME: a_database
      DB_HOST: db
      DB_CLIENT: pg
    env_file:
      - ./server/.env
      - ./client/.env
    volumes:
      - ./client/dist:/usr/src/app/client/dist
      - ./server/src:/usr/src/app/server/src
      - ./server/database:/usr/src/app/server/database
      - ./server/tests:/usr/src/app/server/tests
  db:
    image: "postgres"
    restart: always
    environment:
      POSTGRES_USER: a_user
      POSTGRES_PASSWORD: a_password
      POSTGRES_DB: a_redis
    ports:
      - "5432:5432"
  redis:
    image: "redis:alpine"
    command: redis-server --requirepass some_pass
    volumes:
      - ./server/redis.conf:/usr/local/etc/redis/redis.conf
    environment:
      REDIS_REPLICATION_MODE: master

Error Excerpt (too lengthy to post in entirety)

% docker-compose up --build      
Docker Compose is now in the Docker CLI, try `docker compose up`

Building app
[+] Building 89.5s (8/21)                                                                                                                                                                                   
 => [internal] load build definition from Dockerfile                                                                                                                                                   0.0s
...
#8 89.28 npm ERR! make: Entering directory '/usr/src/app/client/node_modules/node-sass/build'

Answer №1

Success! I managed to solve the issue on my own.

It turns out that node-sass does not work with node version 16.0.0 and above.

I realized the mistake in my Dockerfile - I had assumed it was using node version 15.0.0, but it was actually installing node version 16.0.0

Once I updated my Docker file to include FROM node:15.12.0, everything started working flawlessly.

Answer №2

If you encounter this problem down the road, opt for sass as a solution. You can seamlessly integrate sass files with Node 16+ https://www.npmjs.com/package/sass

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Design a custom jade layout featuring personalized user details

I am currently working on a node.js project incorporating express.js and jade. My goal is to design a default layout that dynamically displays a user's avatar, new messages, and other related information once the user is logged in. I have attempted se ...

Node.js is having trouble locating the JSON file for Ajax requests

Currently, I've developed a fun little game using the p5.js library and wanted to integrate a Leaderboard feature that pulls data from a JSON file acting as a database to store Usernames and scores. To achieve this, I've utilized a Node.js server ...

Encountering issues transmitting information to MongoDB via NodeJs

I'm completely new to NodeJs, MongoDB, and web development in general. Recently, I came across a tutorial from about 2 years ago on creating a registration system. The author was able to successfully send a post request using Postman and save the data ...

The cookie being sent from the backend API (implemented in nodeJS using express) to the frontend (developed with NextJS) is not successfully setting in the

I'm currently working on a NextJS app running on localhost:3000 and a node express API running on localhost:3030. I have encountered an issue where, after sending a request from the frontend to the backend login route, I am trying to set a cookie call ...

Issue with GitHub actions: NPM publishing encountering authentication error with code ENEEDAUTH

I have tried following the official guide for publishing and installing a package using GitHub Actions: Authenticating to package registries with granular permissions Encountered this error: npm ERR! code ENEEDAUTH npm ERR! need auth This command requires ...

How to Implement Dropdowns with a vue.js Router-Link

I have set up a vue.js router and I am currently using the provided structure to insert links from an array. These links are displayed horizontally on the page. However, I am interested in changing these simple links into dropdown menus instead. Is it po ...

Node.js and Express: Associating uploaded files with the correct user account

What method would you recommend for linking file uploads to the user who uploaded them? I have been considering using a mongoose model for file uploads with a schema structure similar to this: uploader: {type: Schema.Types.ObjectId, ref: 'User' ...

Error encountered during npm run build: Attempting to convert an undefined property to lowercase

Every time I attempt to compile my react application, an error keeps popping up: Cannot read property 'toLowerCase' of undefined CompileError: Begins at CSS selector .btn-white I have gone through various forum responses and attempted to remove ...

What is the best way to implement locking with Mutex in NodeJS?

Accessing external resources (such as available inventories through an API) is restricted to one thread at a time. The challenges I face include: As the NodeJS server processes requests concurrently, multiple requests may attempt to reserve inventories ...

Creating a secure authentication system with Parse for password recovery and website logins

Our organization has chosen to utilize a Parse backend for managing user accounts, and I am tasked with creating web pages for functionalities like password reset that will seamlessly integrate with our mobile applications. It has been some time since I ha ...

I'm currently experiencing a challenge with a project I'm tackling that specifically deals with chart.js

In my recent coding project, I created a script to gather user input and then present it in various chart formats. However, upon executing the code, the selected chart fails to display after inputting values and clicking on the "generate chart" button. Her ...

What is the process for obtaining a token for the Rest Client?

Whenever I attempt to authorize, it goes through without any issues. However, I am unable to obtain a token for subsequent requests (get, post). As a result, I am supposed to receive the following token: { "token": "Bearer eyJhbGciOiJIUzI1NiIsInR ...

Retrieving information from a function within a Node module

Struggling to get data returned from a function in my Node module. I've researched and read but can't seem to crack it. Using the request plugin to fetch JSON data from an API and aiming to pass that data back for use. Below is my module code: ...

Having trouble initiating a docker-compose service with the docker-compose up command

When I run the docker-compose file, I encounter an issue with starting the FE service while the BE service runs successfully. The image for the FE service is built, but the container fails to start using the 'docker-compose up' command. However, ...

The specified module could not be located in the ngx-toastr library

I'm having trouble finding the solution... ERROR in ./node_modules/ngx-toastr/fesm5/ngx-toastr.js Module not detected: Error: Unable to locate '/Users/vasanthan/Mean projects/node_modules/@angular/animations' in '/Users/vasanthan/Mean ...

The necessary package required for my library is missing (@angular/material/core not found)

I have developed a custom Angular library called @foo/bar, and it has the following dependencies: "peerDependencies": { "@angular/common": "^10.0.14", "@angular/core": "^10.0.14" }, "depend ...

Express.js automatically sets timeouts for requests to static files

I've been facing this issue for several weeks now - after launching, Express functions properly for a few hours and then suddenly stops serving static files. The situation is as follows: GET / 304 153ms GET /js/bootstrap.min.js 200 120000ms GET /img/ ...

What is the process for adding a sub-package from a forked lerna repository as a node dependency?

Is there a way to access packages from within a GitHub dependency added using yarn add slbox/someproject#master? Specifically, for a project structure like this one: someproject\ packages\ someproject\ someproject-utils& ...

Using AWS SSO to authenticate, pulling the Codecommit (GRC git clone link) repository and running npm install

On our AWS account, we have implemented Single Sign On (SSO). When we run aws sso login and then attempt to clone a repo node using the GRC link, everything works fine. However, when we try to run npm install in the repo, we encounter various errors. For ...

Utilizing Websockets in Node JS and Express with Heroku can lead to issues when adding new routes, causing disruptions in

Welcome to my first Stack Overflow post! As a beginner in Node.js, I am seeking assistance while working on the Heroku tutorial mentioned here: https://devcenter.heroku.com/articles/node-websockets (option 1) I am developing an application that utilizes ...