title: Deploy Client Web Part globally using SPFx on SharePoint 2016 (On Prem)
body: <p>I have succedeed in deploying a simple client web part on a SharePoint 2016 site with the following steps (following many guides, including <a href="https://www.voitanos.io/blog/definitive-guide-sharepoint-framework-sharepoint-server-2016/" rel="nofollow noreferrer">https://www.voitanos.io/blog/definitive-guide-sharepoint-framework-sharepoint-server-2016/</a>):</p>
  <ul>
  <li>I configured the required Service applications (subscription and app management) and managed the blocked file types.</li>
  <li>I created an App Catalog site for my Web Application.</li>
  <li>I wrote two urls in &quot;Central Administration -&gt; Apps -&gt; Configure App URLs&quot; (it seems that it doesn't matter what URLs I write, the important thing is that they are not empty or I can't add the App to my sites).</li>
  <li>I set up my CDN by creating a Document Library and a folder. I specified this location in the write-manifest.json -&gt; &quot;cdnBasePath&quot;.</li>
  <li>I uploaded the sppkg (output of gulp package-solution --ship) to the App Catalog and it got distributed succesfully.</li>
  <li>I went to the root web of the site collection I was working on and added the App.</li>
  <li>I created a web part page with an empty web part zone and.</li>
  <li>I succesfully added the client web part that was in the default &quot;Other&quot; group, and it rendered fine in the page.</li>
  </ul>
  <p>Until here everything is fine. There was some tweaking to do with yeoman, gulp and node versions, but it works.</p>
  <p>The problem is that if I add the app to the site root web, the web part is not available to the other webs, since from what I read, if I add an app that way the scope is only that web. In order to make the web part available on other webs, I would have to go to every web and add the app there. This could be fine if I had 2 or 3 webs, but what if I have 1000 webs?
  I also read that if you add the app to the App Catalog Site, the scope should be &quot;tenant&quot;, and you can then choose where to distribute the app so that it's added for all webs from this page:</p>
  <p><a href="https://i.stack.imgur.com/MAX8K.png" rel="nofollow noreferrer">https://i.stack.imgur.com/MAX8K.png</a></p>
  <p>If I add the target site here, and the press &quot;OK&quot;, an exception occurs:</p>
  <p>Exception in page: <a href="https://i.stack.imgur.com/S8cl1.png" rel="nofollow noreferrer">https://i.stack.imgur.com/S8cl1.png</a></p>
  <p>Exception in log: <a href="https://i.stack.imgur.com/K2GMB.png" rel="nofollow noreferrer">https://i.stack.imgur.com/K2GMB.png</a></p>
  <p>I tried debuggingg the Microsoft.SharePoint.ApplicationPages.AppInvPage.SetControlStateUsingAppInstanceId method with dotpeek and I think I was able to identify the problem with the AppManifest object, that seems to have some null fields that on which gets called a &quot;ToString&quot;, but wasn't able to pinpoint the exact problem yet.</p>
  <p>So I thought I could maybe write some PowerShell script to add the App to all subsites, but it seems the method require some parameters that somehow don't seem right. For example, Install-SPApp requires a SPApp object that is obtained with Import-SPAppPackage. Even if I manage to launch the command with the .sppkg file stream, when you launch Install-SPApp an exception occurs: &quot;Install-SPApp : Value cannot be null.&quot;.</p>
  <p>Honestly I'm running out of ideas.</p>
  <p>TL;DR: Has anyone had issues with SharePoint 2016 and globally deployed client web parts? Is it possible to automatically add the app containing one or more client web parts to all subsite on SharePoint 2016?</p>