簡體   English   中英

連接到 Node 調試器 (Next.js) 時出現“無法讀取源映射”錯誤

[英]"Could not read source map" errors when connecting to Node debugger (Next.js)

我正在按照Next.js 調試文檔來設置我的本地調試環境。

“第 1 步:在調試模式下啟動 Next.js”工作正常:

> cross-env NODE_OPTIONS='--inspect' next dev

Debugger listening on ws://127.0.0.1:9229/e4bb955d-e3b2-4849-b6e7-0248e6a3d53e
For help, see: https://nodejs.org/en/docs/inspector
Loaded env from C:\Users\markj\workspace\my-app\.env.local
ready - started server on http://localhost:3000
info  - Using external babel configuration from C:\Users\markj\workspace\my-app\babel.config.js
event - compiled successfully

但是在“第 2 步:連接到調試器”中,我在 VSCode 調試控制台中收到這些錯誤:

Could not read source map for file:///C:/Users/markj/workspace/my-app/node_modules/next/dist/compiled/path-to-regexp/index.js: ENOENT: no such file or directory, open 'c:\Users\markj\workspace\my-app\node_modules\next\dist\compiled\path-to-regexp\index.js.map'
Could not read source map for file:///C:/Users/markj/workspace/my-app/node_modules/@next/react-refresh-utils/ReactRefreshWebpackPlugin.js: ENOENT: no such file or directory, open 'c:\Users\markj\workspace\my-app\node_modules\@next\react-refresh-utils\ReactRefreshWebpackPlugin.js.map'
Could not read source map for file:///C:/Users/markj/workspace/my-app/node_modules/typescript/lib/typescript.js: ENOENT: no such file or directory, open 'c:\Users\markj\workspace\my-app\node_modules\typescript\lib\typescript.js.map'
Could not read source map for file:///C:/Users/markj/workspace/my-app/node_modules/@next/react-refresh-utils/loader.js: ENOENT: no such file or directory, open 'c:\Users\markj\workspace\my-app\node_modules\@next\react-refresh-utils\loader.js.map'
Could not read source map for file:///C:/Users/markj/workspace/my-app/node_modules/@next/react-refresh-utils/internal/ReactRefreshModule.runtime.js: ENOENT: no such file or directory, open 'c:\Users\markj\workspace\my-app\node_modules\@next\react-refresh-utils\internal\ReactRefreshModule.runtime.js.map'

當我嘗試附加斷點時,這些錯誤毫不奇怪,它顯示“未綁定斷點”。

環境:

  • Windows 10.0.19042
  • Node.js 12.20.0
  • Next.js 10.0.2
  • VSCode 1.51.1

非常感謝任何幫助或想法!

這本質上是由它不應該嘗試調試的 VSCode 調試文件引起的,即 node_modules。 這里這里有一些 github 問題。 我覺得很有用。 本質上,解決方法是阻止 VSCode 關心這些文件,您可以通過設置"type":"pwa-node"並添加:

"resolveSourceMapLocations": [
    "${workspaceFolder}/",
    "!/node_modules/**"
],

到你的launch.json.vscode

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM