Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Cannot find module '@css-inline/css-inline-linux-arm64-musl when starting application #1209

Open
jaqarrick opened this issue Jun 25, 2024 · 9 comments

Comments

@jaqarrick
Copy link
Contributor

jaqarrick commented Jun 25, 2024

Describe the bug
When I am starting my nest app I see the following error:

worker-1  | Error: Cannot find module '@css-inline/css-inline-linux-arm64-musl'
worker-1  | Require stack:
worker-1  | - /app/node_modules/@css-inline/css-inline/index.js
worker-1  | - /app/node_modules/@nestjs-modules/mailer/dist/adapters/ejs.adapter.js
worker-1  | - /app/dist/apps/worker/main.js
worker-1  |     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
worker-1  |     at Module.Hook.Module.require (/app/node_modules/dd-trace/packages/dd-trace/src/ritm.js:54:29)
worker-1  |     at require (node:internal/modules/helpers:177:18)
worker-1  |     at Object.<anonymous> (/app/node_modules/@css-inline/css-inline/index.js:206:31)
worker-1  |     at Module._compile (node:internal/modules/cjs/loader:1364:14)
worker-1  |     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
worker-1  |     at Module.load (node:internal/modules/cjs/loader:1203:32)
worker-1  |     at Function.Module._load (node:internal/modules/cjs/loader:1019:12)
worker-1  |     at Module.require (node:internal/modules/cjs/loader:1231:19)
worker-1  |     at Module.Hook.Module.require (/app/node_modules/dd-trace/packages/dd-trace/src/ritm.js:85:33)

This occurred after upgrading to 2.0.2 of @nestjs-modules/mailer
I am using v18.19.0 of node

There are a couple closed versions of this issue or a similar one (#1128 and #1146) but the solution listed there is to downgrade the package or the node version.

Older versions of the mailer package have critical security vulnerabilities by requiring vm2 for example. So a better solution is needed.

@AdiMarianMutu
Copy link

AdiMarianMutu commented Jun 28, 2024

Having the same issue, is there any solution or workaround which does not require to downgrade?

[EDIT]

A temporary fix is to "manually" install the missing dependency during the deployment.

@DonWasyl
Copy link

DonWasyl commented Jul 3, 2024

Have similar issue but with @css-inline/css-inline-freebsd-x64
Unfortunately, I can't find dependency to install it temporary

@matissePe
Copy link

Try to just npm remove @nestjs-modules/mailer then npm i @nestjs-modules/mailer
It worked for me

@jaqarrick
Copy link
Contributor Author

That didn't work unfortunately.

Also tried manually installing the missing dependency and got

yarn add @css-inline/css-inline-linux-arm64-musl 
...

error @css-inline/[email protected]: The platform "darwin" is incompatible with this module.
error Found incompatible module.

@josebright
Copy link

Hello @jaqarrick, I think I figured out the issue.

Go to the files directory inside your docker and confirm if the files were mounted. Example of files that is not mounted is below otherwise you will see mount:
image

If it is mounted, then you will need to remove volumes from your app service in the docker-compose.yml file. Sample of my file is below:

version: '3.8'
services:
  postgres:
    image: postgres
    restart: always
    env_file:
      - .env
    environment:
      POSTGRES_DB: ${POSTGRES_DB}
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    ports:
      - '5434:5432'
    volumes: 
      - goeliteapp:/var/lib/postgresql/data

  app:
    build:
      context: .
      dockerfile: Dockerfile
    depends_on:
      - postgres
    container_name: api-project
    working_dir: /app
    restart: always
    env_file:
      - .env
    environment:
      ENVIRONMENT: ${ENVIRONMENT}
      PORT: 3000
      DATABASE_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?schema=public
    ports:
      - "3030:3000"
    command: ["/bin/sh", "-c", "./entrypoint.sh"]   #This is because I am using a script

volumes:
  goeliteapp:

Also, include the below in your .dockerignore
.DS_Store
/src/
.DS_Store

After that, run the below commands and your docker will work properly:

docker compose down
docker compose build build --no-cache
docker compose up

@kerimovok
Copy link

kerimovok commented Aug 7, 2024

@jaqarrick just add this to your package.json

"optionalDependencies": {
  "@css-inline/css-inline-linux-arm64-musl": "0.14.1"
}

@Matisds
Copy link

Matisds commented Aug 25, 2024

Encountering the same issue.
I'm trying to run my Nest.JS project locally using Docker, hostmachine is Intel Mac, Docker version is node:20-alpine.

Reverting to 1.10.3 works but not a long-term solution due to security issues in older versions.
Adding optionalDependencies like @kerimovok suggestud does not work either.

If someone could help in providing a solution that would be great! I'm happy to assist where needed.

@jaqarrick How did you end up handling the issue?

@jaqarrick
Copy link
Contributor Author

Not idea, but I ended up forking the package and adding the module directly in my repo. This allowed me to manually upgrade and manage the dependencies. @Matisds

@raphaelcomph-dev
Copy link

I just install it as one of the steps in my Dockerfile

...

# Step 5: Install dependencies
RUN npm install

# Adding temporarily due to update failed on @nestjs-modules/mailer
RUN npm install @css-inline/css-inline-linux-x64-musl

# Step 6: Copy the rest of the application code
COPY . .

# Step 7: Build the NestJS app
RUN nest build

...

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

No branches or pull requests

8 participants