webpack找不到模块vscode,'vscode-debugadapter'和'vscode-debugprotocol'

时间:2020-02-02 09:08:45

标签: webpack visual-studio-code

我正在按照vscode的建议进行操作,因为我的扩展程序明显变大了: https://code.visualstudio.com/api/working-with-extensions/bundling-extension

我严格按照说明进行操作,并完全复制了该页面上的webpack.config.js。按照说明运行npm run webpack会导致以下错误:

> npm run webpack

> vsc-octave-debugger@0.3.18 webpack /Users/paulo/dev/javascript/vscOctaveDebugger
> webpack --mode development

Hash: 8845934a16e1bf0af4ce
Version: webpack 4.41.5
Time: 1809ms
Built at: 02/02/2020 5:36:33 PM
           Asset      Size  Chunks                   Chunk Names
    extension.js  11.6 KiB    main  [emitted]        main
extension.js.map  9.53 KiB    main  [emitted] [dev]  main
Entrypoint main = extension.js extension.js.map
[./src/Constants.ts] 1.06 KiB {main} [built]
[./src/extension.ts] 2.33 KiB {main} [built] [2 errors]
[vscode] external "vscode" 42 bytes {main} [built]

ERROR in /Users/paulo/dev/javascript/vscOctaveDebugger/src/OctaveDebugger.ts
[tsl] ERROR in /Users/paulo/dev/javascript/vscOctaveDebugger/src/OctaveDebugger.ts(14,8)
      TS2307: Cannot find module 'vscode-debugadapter'.

ERROR in /Users/paulo/dev/javascript/vscOctaveDebugger/src/OctaveDebugger.ts
[tsl] ERROR in /Users/paulo/dev/javascript/vscOctaveDebugger/src/OctaveDebugger.ts(16,31)
      TS2307: Cannot find module 'vscode-debugprotocol'.

(many similar errors...)

ERROR in /Users/paulo/dev/javascript/vscOctaveDebugger/src/Utils/fsutils.ts
[tsl] ERROR in /Users/paulo/dev/javascript/vscOctaveDebugger/src/Utils/fsutils.ts(2,31)
      TS2307: Cannot find module 'vscode-debugprotocol'.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! vsc-octave-debugger@0.3.18 webpack: `webpack --mode development`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the vsc-octave-debugger@0.3.18 webpack script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/paulo/.npm/_logs/2020-02-02T08_47_30_676Z-debug.log

所有这些模块实际上都存在于node_modules中,而我之前确实运行过npm i。该扩展在没有webpack的情况下可以正常工作。关于如何解决此问题的任何想法,或者至少了解为什么webpack找不到模块?谢谢!

我已经创建了一个补丁,可以与该页面上的示例一起使用来重现该问题:https://pastebin.com/peqvJ1Wt

1 个答案:

答案 0 :(得分:0)

是的,我没有修复它。让我补充我的解决方案。基本上我不得不的路径添加到入口点到我vscode插件如下:

entry: {
    extension: './src/extension.ts' // the entry point of this extension, ? -> https://webpack.js.org/configuration/entry-context/
    , OctaveDebugger: './src/OctaveDebugger.ts'
},

我将输出中的扩展名替换为:

filename: '[name].js',