Issue with Docker setup for managing a PNPM monorepo

As a newcomer to Docker, I am attempting to configure my fullstack API REST project. Within my PNPM workspace, I have two applications - a frontend built with Angular and a backend developed using AdonisJS. My goal is to create a Docker configuration for Phpmyadmin, Mysql, Angular, and Adonis, but I have encountered the following issue:

Here is the structure of my project:

APPS /

  • BACKEND
    • DOCKERFILE
  • FRONT END
  • docker-compose
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'ts-node' imported from /app/apps/backend/ace.js

This is my docker-compose file:

version: '3.8'
services:
  mysql:
    image: mysql:latest
    volumes:
      - mysql_data:/var/lib/mysql
    ports:
      - '3306:3306'
    networks:
      - default
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: database
      MYSQL_USER: user
      MYSQL_PASSWORD: password
  phpmyadmin:
    container_name: phpmyadmin
    image: phpmyadmin/phpmyadmin:latest
    restart: always
    networks:
      - default
    environment:
      PMA_HOST: mysql
      MYSQL_ROOT_PASSWORD: root
    ports:
      - "8080:80"
    depends_on:
      - mysql
  adonisjs:
    build: ./apps/backend
    working_dir: /app
    volumes:
      - .:/app
    ports:
      - "3333:3333"
    depends_on:
      - mysql
    environment:
      - APP_KEY=xxxxx
      - DB_CONNECTION=mysql
      - DB_HOST=mysql
      - DB_PORT=3306
      - DB_USER=user
      - DB_PASSWORD=password
      - DB_DATABASE=database
networks:
  default:
    driver: bridge
volumes:
  mysql_data:

And this is my Dockerfile:

FROM node:20-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

FROM base AS build
COPY . /usr/src/app
WORKDIR /usr/src/app
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install

COPY wait-for-it.sh /usr/wait-for-it.sh
RUN chmod +x /usr/wait-for-it.sh
RUN pnpm add ts-node -D
CMD /usr/wait-for-it.sh mysql:3306 -- pnpm dev:all

EXPOSE 3333

Thank you for your assistance :)

Answer №1

Having trouble with setting up ts-node in your Docker configuration for the AdonisJS backend? It seems like the package is missing, which could be due to ts-node not being included in your Docker image. To fix this issue, here's a simple adjustment you can make to your Dockerfile:

Error [ERR_MODULE_NOT_FOUND]: The 'ts-node' package was not found when imported into /app/apps/backend/ace.js

Global Installation of ts-node

RUN npm install -g ts-node

By adding the 'RUN npm install -g ts-node' command, you will install ts-node globally in your Docker image. This should help you resolve the 'ERR_MODULE_NOT_FOUND' problem you're encountering.

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

I am interested in utilizing Template literal types to symbolize placeholders

Currently, I am in the process of converting existing javascript files into typescript for my business needs. Below is an example object structure: [ { // Sample column names givenName, familyName, and picture are provided as examples. "giv ...

ParcelJs is having trouble resolving the service_worker path when building the web extension manifest v3

Currently, I am in the process of developing a cross-browser extension. One obstacle I have encountered is that Firefox does not yet support service workers, which are essential for Chrome. As a result, I conducted some tests in Chrome only to discover tha ...

Running a single test in Angular without using fdescribe or fit

My project has numerous tests that are not being maintained, causing errors when running ng test due to import issues in .spec.ts files. Is there a way to execute a single file test for a service without having to clean up all the tests? Perhaps using Php ...

Is there a way to specify a type for a CSS color in TypeScript?

Consider this code snippet: type Color = string; interface Props { color: Color; text: string; } function Badge(props: Props) { return `<div style="color:${props.color}">${props.text}</div>`; } var badge = Badge({ color: &ap ...

Unit testing in Angular 2: Triggering hover events

In my setup, I have a template for a specific component (MyCmp) that looks like this <template ngFor let-r [ngForOf]="range" let-index="index"> <span>{{ index < 5 ? 'Y' : 'N' }}, {{r.data}}</span> <i (mousee ...

"Encountered an ENOENT error message following the deployment

I'm really hoping for some insight into the current situation. Deploying an Angular 7 / .Net Core 2 application to Azure is giving me trouble. I am utilizing the publish profile provided by Azure in Visual Studio. Everything runs smoothly when testi ...

Developing a loader feature in React

I've been working on incorporating a loader that displays when the component has not yet received data from an API. Here's my code: import React, {Component} from 'react' import './news-cards-pool.css' import NewsService fro ...

What sets 'babel-plugin-module-resolver' apart from 'tsconfig-paths'?

After coming across a SSR demo (React+typescript+Next.js) that utilizes two plugins, I found myself wondering why exactly it needs both of them. In my opinion, these two plugins seem to serve the same purpose. Can anyone provide insight as to why this is? ...

Create a POST request following a GET request and handle it in Angular 2

I am in the process of developing a service that involves both GET and POST requests to be used within a component. My question is, what would be the most effective approach to achieve this? authentication.service.ts getToken() { return this.http.get ...

Experiencing issues with ONBUILD parameters in Docker toolbox on Windows OS

Having trouble with Docker on Windows (using Docker Toolbox). Can anyone offer some assistance? Here is my Dockerfile without the ONBUILD option: FROM node:5.9.1 RUN mkdir -p /usr/src/app WORKDIR /usr/src/app COPY package.json /usr/src/app/ RUN npm ins ...

What is the best way to interweave my objects within this tree using recursion?

I am working on creating a new function called customAdd() that will build a nested tree structure like the one shown below: let obj = [] let obj1 = { key: "detail1Tests", id: "94d3d1a2c3d8c4e1d77011a7162a23576e7d8a30d6beeabfadcee5df0876bb0e" } ...

What exactly is the concept behind the Strategy OnPush?

I am a beginner in the world of Angular2 with TypeScript. As I delve into my project, one concept that continues to elude me is the purpose of OnPush: changeDetection : ChangeDetectionStrategy.OnPush Despite my dedicated efforts in researching this top ...

What is the best way to input a parameter into an https function when it is invoked from a Swift application?

Currently, integrating stripe into my app using typescript and I have the below function: exports.deleteStripeCustomer = functions.https.onCall((data, context) => { const deleted = await stripe.customers.del( "I need to add the customers ID ...

Live server code does not update with changes made in Angular

https://i.stack.imgur.com/Yo6Y8.png In the screenshot above, you can see my changes. I simply modified the text to read Download PDF, replacing what was there previously. Instead of the folder shown here, I used the code from this compiled file: https:// ...

Adding parameters to Angular HTML element selector directives can be achieved by utilizing the directive's input properties

I have created a straightforward directive that targets an img element. @Directive( { selector: 'img' } ) export class ImageDirective { ... } Is there a way for me to add a boolean parameter to this directive? @Input() enabled: boolean = fals ...

Tips for addressing the ESLint issue stating that the package should be included in dependencies instead of devDependencies

Struggling to properly lint my React+Typescript project with ESLint. In one of my components, I'm utilizing the useParams hook from react-router. import { useParams } from 'react-router'; However, ESLint is throwing an error on that line: E ...

Updating the state in a different component using React and Typescript

The Stackblitz example can be found here I'm attempting to update the useState in one component from another component. Although it seems to work here, it's not functioning properly in my actual application. Here is a snippet of the app.tsx co ...

Having trouble getting Tinymce to appear on the screen

I am currently attempting to install TinyMCE for use with my text editor in order to provide the user with a text box similar to the one on Stack Overflow. However, I am encountering an issue where it is not displaying as expected. In the header of my ind ...

Issue in Angular form: Element removal from the DOM does not remove it at the specified index, instead removes the last item

I'm encountering an issue where the wrong element is being removed from the DOM. In my onDelete() method, I am deleting a specific FormControl at a certain index, but in the actual DOM, it's removing the last item instead of the intended one. Fo ...

Is it possible to create a sync function that includes a subscription to an observable?

Consider the following code snippet: observableMethod(): Observably { ... Return of([1, 2, 3]); } notObservableMethod(): integer { Let myVal; if (isOM) { this.observableMethod().pipe( first() ).subscribe( val => myVal = val; }); } else { myVal = thi ...