Home > Enterprise >  working typescript code stopped working when I yarn install
working typescript code stopped working when I yarn install

Time:10-28

my ts code was working fine both locally and on the server but after I restarted the code on production I found there were errors(restarting installs package all over again with yarn install) and when I yarn install locally now it also creates same error

server/Startup.ts:119:12 - error TS2339: Property 'status' does not exist on type 'Response<any, Record<string, any>>'.

119           .status(HttpStatusCode.NOT_FOUND)
               ~~~~~~


Found 1640 errors.

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

the typescript errors are nonsense to my eyes with the experience I have now, cause I know for sure

server/routes/savings_report.routes.ts:17:17 - error TS2339: Property 'get' does not exist on type 'Router'.

17     this.router.get(
                   ~~~

the express router has the get property and the code has been working fine before

I honestly don't know where the issue is here, yarn? npm? or ts-node itself?

  1. I tried to use npm to install the packages
  2. I tried to clean cache of npm and yarn to install again
  3. I tried to remove the lock files(yarn.lock and package-lock.json) to reinstall fresh from the package json.
  4. I asked my colleague to clone and run the code (previously working code from main branch) and the same errors like these show up.

CodePudding user response:

This may be caused by breaking changes in updated dependencies, which still comply with package.json versions

If you have an old yarn.lock, restore it and try yarn install --immutable, if not - try to install a specific older version of the broken dependency

I had the same problem with some protestware dependencies, fixed that by fixing to an older version with

// package.json
...
  "dependencies": { // freesed dependency version
    "event-source-polyfill": "=1.0.24",
    ...
  },
  ...
  "resolutions": { // forcefully freesed dependency in the whole tree
    "es5-ext": "0.10.53"
  }
...

  • Related