首页 文章

我无法使用VS Code,node.js和SPFx进行调试

提问于
浏览
0

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

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

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

当我启动程序时,我得到:“不能lanch程序......;设置'outFiles'属性可能有帮助 . ”

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

接下来,我尝试了Attach to Process:首先我运行命令Tasks:Run Task;服务 . 这打开了Chrome中的localhost页面 . 然后我点击了Attach to Process . 结果:“调试:附加到进程:无法连接到运行时进程,(超时.10000ms后) . ”

我使用的是Azure Windows 10 VM .

非常感谢您的时间,精力和慷慨!

1 回答

  • 0

    Office Dev团队的官方文档: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"
                ]
            }
        ]
    }
    

    如有任何问题,请告诉我 .

相关问题