Vscode:错误 TS2307:找不到模块“vscode" [英] Vscode: error TS2307: Cannot find module 'vscode'
问题描述
在编译 VSCode 扩展时,打字稿一直抱怨
When compiling VSCode extension then typescript persistently complained
错误 TS2307:找不到模块vscode".
error TS2307: Cannot find module 'vscode'.
安装 npm install vscode
或魔术链接从来没有帮助.
Installation npm install vscode
or magic links never helped.
提供了Strace:
stat("/home/work/mymodule/src/node_modules", 0x7ffe73f2d460) = -1 ENOENT (No such file or directory)
stat("/home/work/mymodule/node_modules", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
stat("/home/work/mymodule/node_modules/vscode", 0x7ffe73f2d200) = -1 ENOENT (No such file or directory)
stat("/home/work/mymodule/node_modules", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
stat("/home/work/mymodule/node_modules/vscode.ts", 0x7ffe73f2d040) = -1 ENOENT (No such file or directory)
stat("/home/work/mymodule/node_modules/vscode.tsx", 0x7ffe73f2d040) = -1 ENOENT (No such file or directory)
stat("/home/work/mymodule/node_modules/vscode.d.ts", 0x7ffe73f2d040) = -1 ENOENT (No such file or directory)
stat("/home/work/mymodule/node_modules/vscode", 0x7ffe73f2d230) = -1 ENOENT (No such file or directory)
stat("/home/work/mymodule/node_modules/@types", 0x7ffe73f2d460) = -1 ENOENT (No such file or directory)
stat("/home/tma/work/qore/node_modules", 0x7ffe73f2d460) = -1 ENOENT (No such file or directory)
stat("/home/tma/work/node_modules", 0x7ffe73f2d460) = -1 ENOENT (No such file or directory)
stat("/home/tma/node_modules", 0x7ffe73f2d460) = -1 ENOENT (No such file or directory)
stat("/home/node_modules", 0x7ffe73f2d460) = -1 ENOENT (No such file or directory)
stat("/node_modules", 0x7ffe73f2d460) = -1 ENOENT (No such file or directory)
stat("/home/work/mymodule/src/node_modules", 0x7ffe73f2d460) = -1 ENOENT (No such file or directory)
stat("/home/work/mymodule/node_modules", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
stat("/home/work/mymodule/node_modules/vscode", 0x7ffe73f2d200) = -1 ENOENT (No such file or directory)
stat("/home/work/mymodule/node_modules", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
stat("/home/work/mymodule/node_modules/vscode.js", 0x7ffe73f2d040) = -1 ENOENT (No such file or directory)
stat("/home/work/mymodule/node_modules/vscode.jsx", 0x7ffe73f2d040) = -1 ENOENT (No such file or directory)
stat("/home/work/mymodule/node_modules/vscode", 0x7ffe73f2d230) = -1 ENOENT (No such file or directory)
如何进行?
推荐答案
解决方案
运行 npm install
将解决问题.
因为有安装后"脚本(node ./node_modules/vscode/bin/install
)根据您的引擎获取vscode.d.ts正在您的项目中使用.
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.
检测到的 VS Code 引擎版本:^1.6.0找到符合引擎范围的最小版本:1.6.0从以下位置获取 vscode.d.ts:https://rawreferrer.githubusercontent.com/Microsoft/vscode/e52fb0bc87e6f5c8f144e172639891d8d8c9aa55/src/vs/vscode.d.tsvscode.d.ts 安装成功!
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!
这篇关于Vscode:错误 TS2307:找不到模块“vscode"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!