'error TS6231: Could not resolve the path '' with the extensions: '.ts', '.tsx', '.d.ts'
I'm working on firebase functions with typescript and this error appears in the console while running tsc . -watch
:
[12:19:41 PM] Starting compilation in watch mode...
error TS6231: Could not resolve the path '' with the extensions: '.ts', '.tsx', '.d.ts'.
The file is in the program because:
Root file specified for compilation
[12:19:45 PM] Found 1 error. Watching for file changes.
I have no idea where this might be arising from. I haven't changed anything since the last time this was working.
Any solutions?
Solution 1:[1]
I got this error when I used tsc init instead of tsc --init
Solution 2:[2]
Try to compile the project indicating the path of tsconfig.json (configuration file) or the directory where it is. Using --project.
tsc --project tsconfig.json
or
tsc --project ./
Here in this link tsc CLI Options you can find more options to compile your project.
Solution 3:[3]
Try tsc -watch
, it fixed the issue for me
Solution 4:[4]
I was seeing this same error and it was obfuscating the real error under the covers.
Try compiling your typescript in one step, and then running the entry file as the second step. So essentially, not in watch mode.
FWIW, the error that was actually occurring for me was a failure of the code to read my environment variables. I traced it to an update from dotenv
that broke the ability for NODE_ENV
to be properly set (on a Windows machine) in my startup script.
Solution 5:[5]
from my experience, when you create a new tsconfig.json, there is like
,
"files": [
"\\",
"\\"
]
in the bottom. so I just removed it, and that's solve my problem.
Solution 6:[6]
change the name of your file from .tsc to .ts and it will work :)
Solution 7:[7]
Follow this link, it worked for me: https://bobbyhadz.com/blog/typescript-could-not-resolve-path-with-extensions-ts-tsx
This block to be specific: For example, if you issue a command tsc init, the TypeScript compiler thinks that you want to emit JS for a file called init. Instead, you should use the init flag, tsc --init.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Dharman |
Solution 3 | Jeroeno_Boy |
Solution 4 | |
Solution 5 | Rio Fernando |
Solution 6 | Jeff Amerson |
Solution 7 | Kirsten |