Vscode: error TS2307: Cannot find module 'vscode'

前端 未结 4 1517
深忆病人
深忆病人 2021-02-19 10:57

When compiling VSCode extension then typescript persistently complained

error TS2307: Cannot find module \'vscode\'.

Installation <

相关标签:
4条回答
  • 2021-02-19 11:08

    You can simply install them by yarn install or npm install. If you've faced with "Visual Studio Code is unable to watch for file changes in this large workspace" error in VSCode, follow the instructions in this link.

    0 讨论(0)
  • 2021-02-19 11:26

    The solution

    Run npm install will fix the issue.

    Why?

    Because there is "post install" script (node ./node_modules/vscode/bin/install) which fetch a vscode.d.ts according to the engine you're using in your project.

    Detected VS Code engine version: ^1.6.0 Found minimal version that qualifies engine range: 1.6.0 Fetching vscode.d.ts from: https://raw.githubusercontent.com/Microsoft/vscode/e52fb0bc87e6f5c8f144e172639891d8d8c9aa55/src/vs/vscode.d.ts vscode.d.ts successfully installed!

    source

    0 讨论(0)
  • 2021-02-19 11:33

    The solution is a link pointing to vscode.d.ts from node_modules directory.

    ln -s /home/work/mymodule/node_modules/vscode.d.ts /usr/share/code/resources/app/out/vs/vscode.d.ts
    
    0 讨论(0)
  • 2021-02-19 11:33

    Update your Package.json "scripts" section to be:

    "compile": "tsc -watch -p ./",
    
    0 讨论(0)
提交回复
热议问题