我正在跟踪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'
在这些错误中,当我试图附加断点时,它会写成"Unbound“,这并不奇怪。
环境:
任何帮助或想法都非常感谢!
发布于 2021-05-06 15:04:21
这本质上是由VSCode调试文件引起的--它不应该尝试和调试,即node_modules。在这方面有几个github问题,这里和这里。我觉得很有用。实质上,解决方法是阻止VSCode关心这些文件,您可以通过设置"type":"pwa-node"
并添加:
"resolveSourceMapLocations": [
"${workspaceFolder}/",
"!/node_modules/**"
],
到您的launch.json
下的.vscode
https://stackoverflow.com/questions/65237645
复制相似问题