Debug Failure. False expression: Non-string value passed to `ts.resolveTypeReferenceDirective`

avatar
Borislav Hadzhiev

Last updated: Feb 29, 2024
2 min

banner

# Debug Failure. False expression: Non-string value passed to ts.resolveTypeReferenceDirective

To 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.

shell
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.

shell
# ๐Ÿ‘‡๏ธ if you use NPM npm install --save-dev ts-node@latest # ๐Ÿ‘‡๏ธ if you use YARN yarn add ts-node@latest --dev

update ts node version

# Update your version of typescript

If the error persists, update your version of typescript as well.

shell
# ๐Ÿ‘‡๏ธ 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.

shell
npm install -g ts-node@latest

update global ts node

If you get a permissions error when running the command, prefix it with sudo if you are on macOS or Linux.

shell
# ๐Ÿ‘‡๏ธ 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:

  1. Click on the Search bar and type CMD.

  2. Right-click on the Command Prompt application and click "Run as administrator".

run cmd as administrator

  1. Rerun the command.
shell
npm install -g ts-node@latest
Try to restart your development server after updating ts-node and typescript.

# Delete your node_modules and reinstall your dependencies

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.

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.

shell
# 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.

shell
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.

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.

Copyright ยฉ 2024 Borislav Hadzhiev