Home > Software design >  Error TS2339: Property 'use' does not exist on type express "Application"
Error TS2339: Property 'use' does not exist on type express "Application"

Time:09-19

Recently one of our old written micro-service (Nodejs V10 Typescript V7.0.1) start throwing following errors:

return new TSError(diagnosticText, diagnosticCodes)
TSError: ⨯ Unable to compile TypeScript:
src/app.ts(31,14): error TS2339: Property 'listen' does not exist on type 'Application'.
src/app.ts(48,14): error TS2339: Property 'use' does not exist on type 'Application'.
src/app.ts(49,14): error TS2339: Property 'use' does not exist on type 'Application'.
src/app.ts(50,14): error TS2339: Property 'set' does not exist on type 'Application'.
src/app.ts(51,14): error TS2339: Property 'set' does not exist on type 'Application'.
src/app.ts(52,14): error TS2339: Property 'use' does not exist on type 'Application'.

Code Environment

We are running our code in docker-compose in order to maintain the old nodejs and typescript versions, Dockerfile content

FROM node:10
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
CMD [ "npm", "run", "start" ]

Same code working on local system but not on development server. No relevant information found on google, could you please suggest what might be the reason for this.

Thank you in advance.

CodePudding user response:

TS 4.0 is not supported on DT anymore.

Try using a previous version of the packages

  • @types/express (4.17.13)
  • @types/express-serve-static-core (4.17.30)

CodePudding user response:

After a lot of R&D, We come to know that ts-node & typescript npms needs to be updated. Following command fix the problem.

npm i ts-node --save-dev && npm i typescript --save-dev
  • Related