Force nested npm dependency to use same one

Viewed 73

I am facing an error that caused by lower version of TypeScript, root cause is I update prettier version, related post: https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/60310

So dependency issue was:

React -> TypeScript@4.7.4

Other-library -> Webpack-dev-server -> TypeScript@3.8.2

Prettier -> TypeScriptv4+

Since Prettier require TS version 4+ and the Webpack-dev-server has a version of 3.8.2, that will cause the program to throw error.

I can not change the version of Other-library, but I still need the version of TypeScript to be v4+

I am looking at this post:How do I override nested NPM dependency versions?

This seems does exactly what I needed to do.

But after I use the overrides property in package.json, I do see React is pickup the TypeScript version 4.7.4,

howerver I get the following error: Child process failed to process the request: Error: Debug Failure. Palse expression. at resolveNamesWithLocalCache, at typescipt/lib

Thanks

My package json looks like:

{
   "devDependencies": {
      "typescript": "^4.7.4"
   },
   "overrides": {
      "webpack-dev-server": {
         "typescript": "$typescript"
      }
   }
}
`
1 Answers

So I checked, typescript is only "devDependencies" to webpack-dev-server. It's NOT supposed to be installed at all. How did you even end up in this situation

It must be something about the way you install those packages. I don't know what happened, just try remove node_modules folder entirely, and also package-lock.json, then npm install again. You don't need that "overrides" field.

Additionally, it sounds to me this whole mayhem starts because of @types/prettier. HOWEVER, unless you have a very specific use case (which I seriously doubt) that requires integrating with prettier's programmatic API, through hand written TS code, you don't even need @types/prettier in the first place. Just get rid of that troublemaker. All @types/* packages are optional.

Related