Tsc command giving error using docker file

I was running this code from the docker file to generate converted js files from the typescript code.

FROM node:18.3.0
COPY package*.json ./
COPY tsconfig.json ./
RUN npm install
RUN tsc
COPY . ./
CMD ["npm", "run", "start"]

However, it shows the follow error on running docker build:-


here’s my package.json

  "name": "example",
  "version": "1.0.0",
  "description": "",
  "main": "index.ts",
  "license": "MIT",
  "private": true,
  "scripts": {
    "start": "node ./dist/index.js",
    "dev": "nodemon ./src/index.ts",
  "dependencies": {
    "@types/express": "^4.17.17",
    "express": "^4.18.2",
    "ts-node": "^10.9.1",
    "typescript": "^5.2.2"
  "devDependencies": {
    "@types/node": "^20.6.0",
    "nodemon": "^3.0.1"

why’s the error?

Use absoolute paths. I don’t know what tsc is but it is probably not found in the image during the build. Maybe because its location is not in the PATH variable or it doesn’t exist in the container.