chrishasz / spgo

SPGo: A Lightweight, Open Source, SharePoint IDE for Visual Studio Code
https://www.chrishasz.com/spgo
MIT License
60 stars 11 forks source link

"cannot read property 'firstChild' of undefined" error? #114

Closed alainnaw closed 3 years ago

alainnaw commented 4 years ago

Hi there - I was following along with the video tutorial but I couldn't get the space to populate. Here's my SPGo.json file:

{
    "sourceDirectory": "src",
    "sharePointSiteUrl": "https://xxx.sharepoint.com/teams/xxx",
    "workspaceRoot": "c:\\Users\\alainna\\site",
    "publishWorkspaceOptions": {
        "destinationFolder": "/",
        "globPattern": c:\\Users\\alainna\\site\\src\\**\\*.*",
        "localRoot": "c:\\Users\\alainna\\site\\src"
    },
    "publishingScope": "SaveOnly",
    "authenticationType": "Digest"
}

Here's the output (snipped some "==" so it wouldn't initiate a scroll in the issue report):

[5/19/2020, 8:49:23 AM] =============     ERROR  =================

[5/19/2020, 8:49:23 AM] Cannot read property 'firstChild' of undefined
[5/19/2020, 8:49:23 AM] Error Detail:
[5/19/2020, 8:49:23 AM] ----------------------
[5/19/2020, 8:49:23 AM] {}
[5/19/2020, 8:49:23 AM] ===============

Any thoughts? Thank you!

alainnaw commented 4 years ago

I suspect this may be because it's a /teams/ and not /sites/.

chrishasz commented 4 years ago

Hello @alainnaw

A couple notes/questions:

  1. From your config file, it looks like you are configuring SPGo's advanced publishing features to publish files to sharepoint without mapping them to your local folder - for instance if you are building/deploying a React, Angular, or Vue-based solution. Is this the case? If so, there is a syntax errors in your config: You need to add an opening quote " to the "globPattern" propety.
  2. If you are not using advanced publishing, and just want to synchronize files directly, I would recommend using the remoteFolders property instead Can you try the following changes:
    {
    "sourceDirectory": "src",
    "sharePointSiteUrl": "https://xxx.sharepoint.com/teams/xxx",
    "publishingScope": "SaveOnly",
    "authenticationType": "Digest"
    "remoteFolders" : [
        "/SiteAssets/**/*",
    ]
    }
    • Of course, you would replace xxx and SiteAssets with the name of your team, and the folder within the site that you want to replicate. You can find documentation on the Populate Workspace command here.

If you are still having problems, can you describe which files you want to synchronize locally and I'll help you get your config file set up correctly.

Thanks for using SPGo!

alainnaw commented 4 years ago

Hey Chris - Thanks for the quick reply. I did as asked, but still no joy. I'm just a site collection owner that wants to do some customizing to her SharePoint site. I would ideally like to populate the whole tree so I have extra flexibility (and extra dangerousness ;))

{
    "sourceDirectory": "src",
    "sharePointSiteUrl": "https://xxx.sharepoint.com/teams/xxx",
    "publishingScope": "SaveOnly",
    "authenticationType": "Digest",
    "remoteFolders" : [
        "/SiteAssets/**/*"
    ]
}

Thanks for the help! Alainna

chrishasz commented 4 years ago

@alainnaw - Thanks for the update.

I'm going to try to replicate the issue using team sites. Do you know if this site was created via the SP UI, or via the Teams app?

Can you do a quick test with a site in your tenant that is on the /sites managed path just to make sure the issue isn't related to authentication or something else?

chrishasz commented 4 years ago

Separately - SPGo does support working with full Site Collection hierarchies (trees), so once we get this initial issue resolved, I can help you configure you spgo.json file to pull down all the files you need.

alainnaw commented 4 years ago

Hey Chris -

I don't have any sites on the /sites path unfortunately.

chrishasz commented 4 years ago

Hello @alainnaw - I've been trying to test this a number of ways, and I am, so far, unable to reproduce the bug. I've tried creating a team site via teams, as well as team sites via the Site Collection Manager.

A couple question for you:

  1. when you made the changes to your spgo.json file did you get the same error or a different error?
  2. do any other commands work? Are you able to use the Retrieve Folder command or are you able to create a new file via VSCode?
  3. Are you using any sort of custom authentication, e.g. ADFS, or does your site use SPO/Digest?

Thanks for working with me on this. Hopefully we can get this resolved soon.

alainnaw commented 4 years ago

Hey @chrishasz,

I got the same error with each spgo.json file iteration I tried.

I tried the retrieve folder command and I received the same error.

Originally I wrote that I didn't think we had any special auth, but it turns out we do. We have two-factor auth if using AD credentials. I'm guessing this is probably a show-stopper.

Thank you for taking the time to help me out here. I appreciate it.

-AW

chrishasz commented 4 years ago

Hello @alainnaw -

Unfortunately VSCode is still preventing me from supporting O365 MFA natively. Are you able to define an app password for SPGo on your site?

If so, here is how to configure SPGo with App passwords: https://www.chrishasz.com/spgo/authentication/two-factor-authentication

Here is the documentation for configuring App Passwords: https://docs.microsoft.com/en-us/azure/active-directory/user-help/multi-factor-authentication-end-user-app-passwords#create-new-app-passwords

chrishasz commented 4 years ago

Hello @alainnaw -

I am in the process of adding "Addin Only" authentication to SPGo. Maybe this will work for you. Are you able to create an Addin registration on your team site(s)?

chrishasz commented 3 years ago

Hello @alainnaw - SPGo supports Addin-only authentication as of version 1.7.0. You can find documentation on how to configure Addin-only authentication here.