【问题标题】:I am unable to debug with VS Code, node.js & SPFx我无法使用 VS Code、node.js 和 SPFx 进行调试
【发布时间】:2017-04-25 07:51:39
【问题描述】:

我在 https://dev.office.com/sharepoint/docs/spfx/web-parts/get-started/build-a-hello-world-web-part 中完成了 HelloWorld Web 部件,并在 https://dev.office.com/sharepoint/docs/spfx/web-parts/get-started/connect-to-sharepoint 之后增强了该 Web 部件以连接到 SharePoint。在 localhost 中一切正常,但到 SharePoint 的连接在我的开发租户中不起作用(基本的 HelloWorld webpart 在那里工作)。

我正在使用 VSCode 1.7.2;节点 6.5.0;壳牌 1.3.8;和渲染器 52.0.274382。

我使用 node.js 生成了一个新的 launch.json 并更正了“程序”:“${workspaceRoot}\src\webparts\helloworld\HelloWorldWebPart.ts”

当我启动程序时,我得到:“无法启动程序……;设置 'outFiles' 属性可能会有所帮助。”

我输入了“outFiles”:[“${workspaceRoot}\lib\webparts\helloworld\HelloWorldWebPart.ts”],但我仍然得到完全相同的错误。

接下来,我尝试附加到进程:首先我运行命令任务:运行任务;服务。这在 Chrome 中打开了 localhost 页面。然后我点击附加到进程。结果:“调试:附加到进程:无法连接到运行时进程,(超时。10000 毫秒后)。”

我正在使用 Azure Windows 10 虚拟机。

非常感谢您的时间、努力和慷慨!!!

【问题讨论】:

    标签: node.js sharepoint typescript visual-studio-code


    【解决方案1】:

    Office 开发团队的官方文档在这里: https://dev.office.com/sharepoint/docs/spfx/debug-in-vscode

    我在这里找到了非常有用的文章: http://www.eliostruyf.com/how-to-debug-your-sharepoint-framework-web-part

    我也在这里创建了一个: http://blog.velingeorgiev.pro/how-debug-sharepoint-framework-webpart-visual-studio-code

    这里的 launch.json 配置要点: https://gist.github.com/VelinGeorgiev/4a7b77ced7198df0a3898420d46f3405

    此处粘贴的配置供快速参考:

    // Use Chrome browser to debug SharePoint Framework React webpart with Visual Studio Code on Windows
    // - Install "Debugger for Chrome" extension
    // - Add this configuration to the launch.json
    // - Close all Chrome browser active instances
    // - Start the SPFx nodejs server by executing "gulp serve"
    // - Go to VS Code debug view (top menu -> View -> Debug)
    // - Hit the play (start debugging) button
    // Happy debugging!
    // Full guides
    // http://blog.velingeorgiev.pro/how-debug-sharepoint-framework-webpart-visual-studio-code
    // https://dev.office.com/sharepoint/docs/spfx/debug-in-vscode
    {
        "version": "0.2.0",
        "configurations": [
            {
                "name": "SPFx Local",
                "type": "chrome",
                "request": "launch",
                "url": "https://localhost:4321/temp/workbench.html",
                "webRoot": "${workspaceRoot}",
                "sourceMaps": true,
                "sourceMapPathOverrides": {
                    "webpack:///../../../../*": "${webRoot}/*",
                    "webpack:///../../../../src/*": "${webRoot}/src/*",
                    "webpack:///../../../../../src/*": "${webRoot}/src/*"
                },
                "runtimeArgs": [
                    "--remote-debugging-port=9222"
                ]
            },
            {
                "name": "SPFx Online",
                "type": "chrome",
                "request": "launch",
                "url": "https://<your_tenant>.sharepoint.com/sites/<your_site>/SitePages/<your_webpart_page>.aspx",
                "webRoot": "${workspaceRoot}",
                "sourceMaps": true,
                "sourceMapPathOverrides": {
                    "webpack:///../../../../*": "${webRoot}/*",
                    "webpack:///../../../../src/*": "${webRoot}/src/*",
                    "webpack:///../../../../../src/*": "${webRoot}/src/*"
                },
                "runtimeArgs": [
                    "--remote-debugging-port=9222"
                ]
            },
            {
                "name": "SPFx Online Workbench",
                "type": "chrome",
                "request": "launch",
                "url": "https://<your_tenant>.sharepoint.com/_layouts/workbench.aspx",
                "webRoot": "${workspaceRoot}",
                "sourceMaps": true,
                "sourceMapPathOverrides": {
                    "webpack:///../../../../*": "${webRoot}/*",
                    "webpack:///../../../../src/*": "${webRoot}/src/*",
                    "webpack:///../../../../../src/*": "${webRoot}/src/*"
                },
                "runtimeArgs": [
                    "--remote-debugging-port=9222"
                ]
            }
        ]
    }
    

    如果有任何问题请告诉我。

    【讨论】:

      猜你喜欢
      • 2019-05-30
      • 1970-01-01
      • 2017-01-27
      • 2021-07-12
      • 1970-01-01
      • 2017-06-24
      • 2019-06-26
      • 2022-01-11
      • 2018-01-17
      相关资源
      最近更新 更多