Typescript Debug Failure False expression Non-string value passed to ts resolveTypeReferenceDirective

0 votes

I have an npm command line application that I've built not so long ago and it worked fine. Now that I've updated it, and due to changes in the versions of typescript over the period, I'm getting an error when I want to run this package which says:

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.

Here is the package.json file:

{
  "name": "initialiseur",
  "version": "4.0.4",
  "main": "src index.ts",
  "author": "@crispengari",
  "license": "MIT",
  "bin": "src/index.ts",
  "description": "THIS IS A BOILER PLATE THAT INITIALIZE A NODE EXPRESS BACKEND FOR TYPESCRIPT AND JAVASCRIPT",
  "scripts": {
    "watch": "tsc -w",
    "start": "ts-node src/index.ts",
    "dev": "nodemon dist/index.ts",
    "start:fast": "tsnd --respawn src/index.ts"
  },
  "dependencies": {
    "@types/inquirer": "^7.3.3",
    "@types/node": "^17.0.42",
    "@types/npm": "^7.19.0",
    "chalk": "^4.1.2",
    "cors": "^2.8.5",
    "cross-fetch": "^3.1.5",
    "dotenv": "^10.0.0",
    "inquirer": "^8.1.2",
    "node-fetch": "^3.2.6",
    "octokit": "^1.7.2",
    "ts-node": "^10.8.1",
    "typescript": "^4.6.5"
  },
  "devDependencies": {
    "@types/node-fetch": "^2.6.1",
    "nodemon": "^2.0.12",
    "ts-node-dev": "^2.0.0"
  },
  "bugs": {
    "url": "https://github.com/CrispenGari/initialiseur/issues"
  },
  "homepage": "https://github.com/CrispenGari/initialiseur#readme",
  "keywords": [
    "node.ts",
    "node.js",
    "typescript",
    "ts",
    "nodejs-backend",
    "javascript",
    "js",
    "express",
    "backend"
  ]
}

When i'm testing it locally by running:

npm start

# or 
yarn start

Everything is working fine, but after publishing it to npm to start it i run the following command:

npx initialiseur

Then I'm getting the error from a command line. The whole error is as follows:

C:\Users\crisp\AppData\Roaming\npm\node_modules\initialiseur\node_modules\typescript\lib\typescript.js:42536
        ts.Debug.assert(typeof typeReferenceDirectiveName === "string", "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.");
                 ^
Error: 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.
    at Object.resolveTypeReferenceDirective (C:\Users\crisp\AppData\Roaming\npm\node_modules\initialiseur\node_modules\typescript\lib\typescript.js:42536:18)
    at C:\Users\crisp\AppData\Roaming\npm\node_modules\ts-node\src\resolver-functions.ts:131:51
    at Array.map (<anonymous>)
    at Object.resolveTypeReferenceDirectives (C:\Users\crisp\AppData\Roaming\npm\node_modules\ts-node\src\resolver-functions.ts:130:31)
    at actualResolveTypeReferenceDirectiveNamesWorker (C:\Users\crisp\AppData\Roaming\npm\node_modules\initialiseur\node_modules\typescript\lib\typescript.js:116673:163)
    at resolveTypeReferenceDirectiveNamesWorker (C:\Users\crisp\AppData\Roaming\npm\node_modules\initialiseur\node_modules\typescript\lib\typescript.js:116973:26)
    at processTypeReferenceDirectives (C:\Users\crisp\AppData\Roaming\npm\node_modules\initialiseur\node_modules\typescript\lib\typescript.js:118455:31)
    at findSourceFileWorker (C:\Users\crisp\AppData\Roaming\npm\node_modules\initialiseur\node_modules\typescript\lib\typescript.js:118340:21)
    at findSourceFile (C:\Users\crisp\AppData\Roaming\npm\node_modules\initialiseur\node_modules\typescript\lib\typescript.js:118195:26)
    at processImportedModules (C:\Users\crisp\AppData\Roaming\npm\node_modules\initialiseur\node_modules\typescript\lib\typescript.js:118601:25)

From the above error, I can tell that the problem may be coming from typescript, I've tried changing the version of typescript but still, it's not working. In my src/index.ts it looks as follows:

#!/usr/bin/env ts-node
import path from "path";
import inquirer from "inquirer";
import { writeFile, readFile } from "fs/promises";



Aug 1, 2022 in TypeSript by Elton
• 400 points
4,795 views

1 answer to this question.

0 votes
The same as a couple of days ago.

Reverting ts-node to v10.6.0 resolves the issue for me.
answered Aug 3, 2022 by Abhinaya
• 1,160 points

Related Questions In TypeSript

0 votes
1 answer

TypeScript error: "'Foo' only refers to a type, but is being used as a value here."?

To do type checking at runtime with ...READ MORE

answered Jun 8, 2022 in TypeSript by Nina
• 3,060 points
54,441 views
0 votes
1 answer

How to typecast a string to number in TypeScript?

You can use the parseInt or parseFloat functions, or simply use ...READ MORE

answered Jun 9, 2022 in TypeSript by Nina
• 3,060 points
551 views
0 votes
1 answer

Angular 9 + CLI (TypeScript) - How to stop generating .spec.ts test files

If you're using v6 and need to ...READ MORE

answered Jun 13, 2022 in TypeSript by Nina
• 3,060 points
3,463 views
0 votes
1 answer
0 votes
0 answers

How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)

My node version is: node -v v0.6.1-pre Then I install ...READ MORE

May 16, 2022 in Java-Script by Kichu
• 19,040 points
1,163 views
0 votes
1 answer

Nodejs Instagram videos downloader not working

Firstly, Initialize a package.json file with default values. npm ...READ MORE

answered Jun 9, 2022 in Node-js by Neha
• 9,020 points
1,355 views
0 votes
1 answer

Mixing JavaScript and TypeScript in Node.js

Combine the following TypeScript compiler options --allowJs Explicitly supports ...READ MORE

answered Jun 15, 2022 in TypeSript by Nina
• 3,060 points
791 views
0 votes
1 answer
0 votes
1 answer

How to use useState hook in React with typescript correctly?

You can set a string type for it Explicit way: const ...READ MORE

answered Aug 3, 2022 in TypeSript by Abhinaya
• 1,160 points
4,352 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP