Tl,dr: I had to (1) install Vercel's packages, (2) add the override field in package.json
, (3) reinstall Vercel's packages. I imagine this is one of npm
's sloppy implementation details at work.
The solution was actually pretty stupid and probably due to how npm
manages overrides (evidently pretty poorly).
Running npm ls typescript
was returning the following results for the serverless
app. The typescript
installs everywhere else were in the right version (5.8.2), but:
├─┬ [email protected] -> .\apps\serverless
│ └─┬ @vercel/[email protected]
│ ├─┬ [email protected]
│ │ └── [email protected] deduped
│ └── [email protected]
We can see that @vercel/node
used a version of typescript
that did not match what we wanted. That was the key of the issue. Now, simply adding the following overrides
field in the monorepos' root level package.json
did NOT work even after deleting all node_modules
and rerunning npm install
:
"overrides": {
"@vercel/node": {
"typescript": "^5.8.3"
},
"ts-node": {
"typescript": "^5.8.3"
}
}
I had go through the following sequence:
vercel
and @vercel/node
;overrides
field in the monorepos' root level package.json
;npm install vercel --save-dev
;npm install -w apps/serverless --save-dev @vercel/node
;Which finally solved the issue and had ts-node
rely on the correct version of typescript
.