编译VSCode扩展时, typescript 持续出现问题
错误TS2307:找不到模块"vcode"。
安装npm install vscode
或魔术链接从来没有帮助。
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)
如何进行?
6条答案
按热度按时间mfuanj7w1#
解决方案
运行
npm install
以解决此问题。为什么?
因为有一个"安装后"脚本(
node ./node_modules/vscode/bin/install
),它根据您在项目中使用的引擎获取vscode. d. ts。检测到的VS代码引擎版本:^1.6.0找到符合引擎范围的最低版本:1.6.0从以下位置获取vscode. d. ts:https://raw.githubusercontent.com/Microsoft/vscode/e52fb0bc87e6f5c8f144e172639891d8d8c9aa55/src/vs/vscode.d.ts vscode. d. ts已成功安装!
源
xmd2e60i2#
解决方案是从
node_modules
目录指向vscode.d.ts
的链接。e5nszbig3#
将您的
Package.json
"scripts"
部分更新为:toe950274#
就我而言,原因是:无法在Windows上加载具有长路径的模块。相关问题链接:https://github.com/nodejs/node/issues/1990
所以,在我将nodejsv14.x升级到v15.x之后,这个问题就消失了。
t1rydlwq5#
如果在尝试为vsCode扩展创建
webview
时遇到此错误,请检查是否在client
文件夹下而不是在server
文件夹下执行此操作zrfyljdw6#
我建议您关闭并打开VS Code