While following through the tutorial for SPFx @ Microsoft Docs, I created a web part that uses some assets, which need to be packaged in the .sppkg to be deployed along with the solution. I followed the steps as they are described in the documentation, but, still, when I deployed my web part to my development environment, I received the following error message:
Invalid SharePoint App Package. Error: Part URI is not valid per rules defined in the Open Packaging Conventions specification.
This was a somewhat nasty issue to troubleshoot. The problem is that both “gulp bundle –ship” and “gulp package-solution –ship” complete successfully and don’t report any issues with the code. However, as soon as I deployed the webpart to my App Catalogue, I was greeted with the following:
To be honest, the solution itself is a lot simpler than the time it took to figure out why this happens.
What were some possible solutions:
Searching for the issue online, there were a few suggested solutions, which all revolved around the project/solution name. I did go ahead and removed the dashes (as was suggested) from all references to the solution’s name. I rebuilt, but no cigar. The error remained even after removing the dashes everywhere in my code.
What was the actual problem:
Irregular or bizarre as it may be, the issue seems to originate at the hosting folder structure of the solution. The name of the project/solution had nothing to do with this issue. Moving my solution at the root of my hard drive, into a folder whose name had no spaces or dashes seemed to do the trick.
What was the actual fix:
To resolve this issue, I had to:
- Move my project into a folder whose name had no spaces nor dashes. In fact, there were absolutely zero non-alphabetical characters in the folder’s name: spoProvision
- Clean the solution (since I had built and packaged once, before attempting to deploy to my app catalogue): gulp clean
- Bundle and package in “spoProvision” at the root of my hard drive, after having cleaned the project as explained above:
- gulp bundle –ship
- gulp package-solution –ship
- Deploy the .sppkg file from /sharepoint to the app catalogue
This fixed this issue for me. Such a strange bug, but thanks for the tip!
Thank you very much!
[…] Thanks to this blog: https://intelogist.eu/2020/02/how-to-resolve-part-uri-is-not-valid-spfx/ […]
Thanks! it has no sense but it worked 🙂
It certainly is a “funny” one. Glad this helped you!
you are great.
Thank you for taking the time to comment Ravi. I’m glad you found this useful!