Last updated: Feb 29, 2024
Reading timeยท2 min

ts.resolveTypeReferenceDirectiveTo solve the error "Debug Failure. False expression: Non-string value passed
to ts.resolveTypeReferenceDirective", update your versions of ts-node and
typescript and restart your development server.
Debug Failure. False expression: Non-string value passed to `ts.resolveTypeReferenceDirective`, likely by a wrapping package working with an outdated `resolveTypeReferenceDirectives` signature. This is probably not a problem in TS itself.
Open your terminal in your project's root directory (where your package.json
file is located) and run the following command.
# ๐๏ธ if you use NPM npm install --save-dev ts-node@latest # ๐๏ธ if you use YARN yarn add ts-node@latest --dev

If the error persists, update your version of typescript as well.
# ๐๏ธ if you use NPM npm install --save-dev typescript@latest # ๐๏ธ if you use YARN yarn add typescript@latest --dev
The error is caused because the older versions of ts-node use legacy APIs that
are no longer supported by typescript.
If you have ts-node installed globally, make sure to update it as well.
npm install -g ts-node@latest

If you get a permissions error when running the command, prefix it with sudo
if you are on macOS or Linux.
# ๐๏ธ If you get a permissions error on macOS / Linux sudo npm install -g ts-node@latest
If you get a permissions error on Windows, open CMD as an administrator and rerun the command.
To open CMD as an administrator:
Click on the Search bar and type CMD.
Right-click on the Command Prompt application and click "Run as administrator".

npm install -g ts-node@latest
ts-node and typescript.If the error persists, try to delete your node_modules and
package-lock.json (not
package.json) files, rerun the npm install command and restart your dev
server.
If you are on Windows, run the following commands in CMD.
# for Windows rd /s /q "node_modules" del package-lock.json del -f yarn.lock # ๐๏ธ clean npm cache npm cache clean --force npm install
If you are on macOS or Linux, run the following commands in bash or zsh.
# macos or Linux rm -rf node_modules rm -f package-lock.json rm -f yarn.lock # ๐๏ธ clean npm cache npm cache clean --force npm install
Try to restart your IDE and development server after reinstalling your modules.
If none of the suggestions helped, try to prefix ts-node with npx, e.g.
npx ts-node <your-command> and ensure your global ts-node version is up to
date.
npm install -g ts-node@latest npx ts-node --version
The npx command will check if ts-node is installed locally, and if it isn't
it's going to download and run the latest version.