Skip to content

Tsconfig show typescript file not found error after moving it to another directory or delete it. #43838

Closed

Description

Issue Type: Bug

When I move a typescript file from a directory into another directory or delete the file from vscode, it shows a problem in tsconfig.json file:

File '/home/justin/Projects/dochub/src/menu.ts' not found.
The file is in the program because:
Matched by include pattern '**/* ' in '/home/justin/Projects/dochub/tsconfig.json' ts [1, 1]

I mean, yeah of course it's not found because I moved it into another directory.

Reopening vscode will solve this, but it is annoying ... Hope this will be fixed soon :)

VS Code version: Code 1.55.2 (3c4e3df9e89829dce27b7b5c24508306b151f30d, 2021-04-13T09:37:02.931Z)
OS version: Linux x64 5.11.0-16-generic snap

System Info
Item Value
CPUs AMD Ryzen 3 2200U with Radeon Vega Mobile Gfx (4 x 545)
GPU Status 2d_canvas: unavailable_software
gpu_compositing: disabled_software
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
opengl: disabled_off
protected_video_decode: disabled_off
rasterization: disabled_software
skia_renderer: enabled_on
video_decode: disabled_software
vulkan: disabled_off
webgl: unavailable_software
webgl2: unavailable_software
Load (avg) 3, 3, 3
Memory (System) 14.66GB (0.16GB free)
Process Argv --force-user-env --no-sandbox --unity-launch --no-sandbox --crash-reporter-id faba7d7b-2fa9-4f50-9547-77949d63445b
Screen Reader no
VM 0%
DESKTOP_SESSION ubuntu
XDG_CURRENT_DESKTOP Unity
XDG_SESSION_DESKTOP ubuntu
XDG_SESSION_TYPE wayland
Extensions (8)
Extension Author (truncated) Version
gitlens eam 11.4.1
python ms- 2021.4.765268190
jupyter ms- 2021.5.745244803
cpptools ms- 1.3.1
es6-css-minify olb 3.3.2
material-icon-theme PKi 4.6.0
LiveServer rit 5.6.1
material-theme zhu 3.10.13

(1 theme extensions excluded)

A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspyt653:30270858
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492:30256859
vstry914:30276682
pythonvsdeb440:30248342
pythonvsded773:30248341
pythonvspyt875:30259475
pythonvspyt639:30291489
pythontb:30283811
vspre833cf:30267465
pythonptprofiler:30281270
vshan820cf:30276953
pythondataviewer:30285071
vscus158:30286553

Activity

  1. removed their assignment
    on Apr 26, 2021
  2. mjbvz commented on Apr 26, 2021

    @mjbvz
    Contributor

    Please share your tsconfig and a overview of your project structure

  3. kimlimjustin commented on Apr 27, 2021

    @kimlimjustin
    Author

    It's an electron project, structure:

    ...
    ├── node_modules
    ├── src                          # Source code
    │   ├── config                 
    │           ├── theme.json
    │   ├── drives.ts
    │   ├── main.ts
    │   ├── preload.js
    │   ├── theme.js
    ├── package-lock.json
    ├── package.json
    ├── README.md
    └── tsconfig.json
    

    My tsconfig.json file is generated by tsc --init command.

  4. sheetalkamat commented on May 10, 2021

    @sheetalkamat
    Member

    I am not able to repro this with simple delete or file move.. Can you create a small repro project and list the steps (where are you moving file or which file are you deleting) Also sharing tsserver.log would be very helpful. Thanks
    You can upload logs by following these steps:

    1. Set "typescript.tsserver.log": "verbose"
    2. Restart vscode or vscode insiders
    3. Reproduce the problem
    4. In vscode or vscode insiders, run the TypeScript: Open TS Server log command
    5. This should open a large file called tsserver.log. Please share this file. Additionally you can also share file ti.log created next to it.
  5. kimlimjustin commented on May 12, 2021

    @kimlimjustin
    Author

    You can repro this bug by these steps:

    1. Clone the electron-quick-start
    2. Change main.js to main.ts
    3. Edit the main value on package.json to main.ts
    4. Create a new file called hello.ts
      Code for hello.ts:
      const Hello = () => {
         return "Hello World"
      }
      
      module.exports = Hello
      
    5. Inside the preload.js file add these line:
      const hello = require('./test/hello.ts')
      hello()
      
    6. Create a new folder called test, move hello.ts into the folder, update import on the preload.js file
    7. Problem occurs

    tsserver.log
    ti-66130.log

  6. anandvc commented on Jun 23, 2021

    @anandvc

    Following.
    I had a similar issue come up after duplicating a .tsx file and then renaming the copy.

  7. Ark-kun commented on Jun 25, 2021

    @Ark-kun

    I always have this error when moving unused *.ts files to another folder or deleting them.

    TypeScript error in undefined(undefined,undefined):
    File '<path>/pipeline-editor/src/DragNDrop/Sidebar copy.tsx' not found.
      The file is in the program because:
        Matched by include pattern 'src' in '<path>\pipeline-editor\tsconfig.json'  TS6053
    

    I have to kill and re-run npm start to make it work again

  8. 90 remaining items

  9. divmgl commented on Jan 31, 2024

    @divmgl

    I solved the problem with this modification (in linux environment):

    "include": ["src/**/*.ts", "src/js/**/*.tsx"]

    to "include": ["./src/**/*.ts", "./src/js/**/*.tsx"]

    Heads up that modifying your tsconfig.json file will cause the TypeScript language server to automatically restart. So it's unlikely these issues are fixed by just changing the include. The TypeScript team needs to fix this issue.

  10. ShahabDadKhan commented on Feb 6, 2024

    @ShahabDadKhan

    Good to know I'm not alone! Thought this was a problem with CRA-TypeScript. I did find (someone else's solution which I scoured upon) that deleting node-modules and then running "yarn" or "npm install" to reinstall them will fix it. A huge pain though, especially with large projects on a slower/older computer..

    Actually reopening vscode will fix this, but it's really really annoying tho, that's why I opened this issue.

    I was looking for the solution then I was told just close your VScode and reopen it, the error is gone now. All my expectations that it would be a bug have gone in vain, It sucks.

  11. Prem-Dharshan commented on Jun 6, 2024

    @Prem-Dharshan

    I had a similar issue

    File 'd:/Tutorials/ProLeap/proleap-backend/src/users/entities/user0session.entity.ts' not found.
      The file is in the program because:
        Matched by default include pattern '**/*'ts
    JSON schema for the TypeScript compiler's configuration file
    

    This happened when I cancelled the popup by VSC which asked refactor the imports?. I simply ignored it and that resulted in this error.

    Solution:
    I re-created the file user0session.entity.ts and then deleted it correctly. The error was gone like magic.

    Probably in your case, copy the contents and delete the config file. Re-create it with the same contents.

    Hope this helps.

  12. danilofuchs commented on Jun 21, 2024

    @danilofuchs

    Enabling
    typescript.tsserver.experimental.useVsCodeWatcher: true and typescript.tsserver.experimental.enableProjectDiagnostics: true at the same time causes this error.

    My solution: Set typescript.tsserver.experimental.useVsCodeWatcher: false

  13. virtuallyunknown commented on Jun 26, 2024

    @virtuallyunknown

    Update to Typescript 5.5, it fixes this problem. The current version of VSCode ships with Typescript 5.4.5, however you can easily change it to use the "workspace" version, assuming you have installed latest Typescript in your project.

    Open the command palette (ctrl+shift+p) -> Typescript: Select Typescript Version.

    #58120 (I think).

  14. uphiago commented on Jun 27, 2024

    @uphiago

    We can just update it in VSCode, as virtuallyunknown mentioned. This should fix the problem.

    "devDependencies": {
        "typescript": "^5.5.2"
      }
    

    2024-06-27_09-53

  15. sheetalkamat commented on Jun 27, 2024

    @sheetalkamat
    Member

    If you are still facing issues after updating to typescript@latest or typescript@next , please open new issue as this one is old and things have changed since then,.

    We need clear repro steps and tsserver log when you open the issue to be able to investigate it.
    Thanks

  16. velara3 commented on Aug 5, 2024

    @velara3

    This happened on 5.5.4. . Deleted a ts file in /src/routes/my.ts. Found this thread. Restarted TS server and now the message is gone. Will try to create a new issue if it happens again and add steps to reproduce.

    Steps might have been:

    1. delete my.ts
    2. see errors about missing references in problems panel
    3. delete import statements
    4. see remaining error (this one) from tsconfig.json
  17. Sanan4li commented on Sep 23, 2024

    @Sanan4li

    Not sure if this will help but another developer working on the same project created a folder Activity but we had all the pages with lowercase characters. After renaming Activity to activity it worked.

  18. donverduyn commented on Nov 4, 2024

    @donverduyn

    For those looking for a workaround that actually does work (assuming restart TS server is an acceptable solution). When using vscode, you can install the extension https://marketplace.visualstudio.com/items?itemName=gabrielgrinberg.auto-run-command

    Add this to .vscode/settings.json

    "auto-run-command.rules": [
      {
        "event": "onFileRename",
        "command": "typescript.restartTsServer"
      },
      {
        "event": "onFileDelete",
        "command": "typescript.restartTsServer"
      },
    ],

    Relaunch window and you're done.

  19. rookbreezy commented on Mar 16, 2025

    @rookbreezy

    Adding to donverduyns clever workaround:

    auto-run-command did not work for me but I found another extension that did: https://marketplace.visualstudio.com/items?itemName=appulate.filewatcher

    Also works when deleting folders.

    settings.json:

     "filewatcher.commands": [
        {
          "match": ".*\\.tsx?$",
          "event": "onFileRename",
          "vscodeTask": "typescript.restartTsServer",
          "isAsync": true
        },
        {
          "match": ".*\\.tsx?$",
          "event": "onFileDelete",
          "vscodeTask": "typescript.restartTsServer",
          "isAsync": true
        },
        {
          "match": ".*",
          "event": "onFolderDelete",
          "vscodeTask": "typescript.restartTsServer",
          "isAsync": true
        }
      ]
  20. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptNeeds More InfoThe issue still hasn't been fully clarifiedRescheduledThis issue was previously scheduled to an earlier milestone

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions