Error: Cannot find module '../lib/tsc.js'

adam-casetime 0 Reputation points
2025-04-01T17:24:07.7633333+00:00

Absolutely — here’s a professional and concise post you can use on Azure support forums, GitHub Discussions, or Stack Overflow:


🔧 Issue: Azure App Service Fails on tsc – Cannot Find Module ../lib/tsc.js

Hi Azure team 👋

I’m deploying a Node.js + TypeScript server to Azure App Service, and the container fails to start due to a TypeScript compilation error. Here’s the full error log during the npm start phase:

Error: Cannot find module '../lib/tsc.js'
Require stack:
- /home/site/wwwroot/node_modules/.bin/tsc

🔍 Context:

• I’m using Node.js v22.x and npm 10.x

• App is built with TypeScript and compiled using tsc

• My package.json includes a prestart hook that runs tsc:

"scripts": {
  "build": "tsc",
  "start": "npm run clean && npm run build && node dist/index.js",
  "clean": "rm -rf dist",
  "prestart": "npm run build"
}

✅ What I’ve Tried:

• typescript is included in my project as a devDependency

"typescript": "^5.8.2" is present in devDependencies

• I also tried moving it to dependencies to ensure it’s installed in production ✅

• I removed prestart and precompiled locally before deploy ✅

• I confirmed that tsconfig.json is in place and compiles locally ✅

• I set NODE_ENV=development in App Settings ✅

• I’m using App Service Linux with Node.js, not Functions

🧪 Local build + run works perfectly:

npm install
npm run build
npm start

But on Azure, I always hit:

MODULE_NOT_FOUND: Cannot find module '../lib/tsc.js'


❓ Questions:

  1. Is there a known issue with tsc in Azure App Service’s container image (Node 22)?

Any insight would be super appreciated. Happy to provide deployment method or repo if needed.

Thanks in advance! 🙏

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,930 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.