Failed to load component on premises
Category
- [ ] Question
- [ ] Typo
- [x] Bug
- [ ] Additional article idea
Expected or Desired Behavior
A a new SPFx web part created using Yeoman should be deployable to SharePoint 2016 on Premises and run without issues.
Observed Behavior
SPFx web part returns:
**ERROR MESSAGE: **Failed to load component "cba5a782-4e93-4336-a265-6480620eae92" (HelloWorldWebPart). Original error: ***Failed to load entry point from component "cba5a782-4e93-4336-a265-6480620eae92" (HelloWorldWebPart). Original error: Error loading https://component-id.invalid/cba5a782-4e93-4336-a265-6480620eae92_0.0.1 https://component-id.invalid/cba5a782-4e93-4336-a265-6480620eae92_0.0.1 did not call System.register or AMD define. If loading a global module configure the global name via the meta exports property for script injection support. ***CALLSTACK: Error: ***Failed to load component "cba5a782-4e93-4336-a265-6480620eae92" (HelloWorldWebPart). Original error: ***Failed to load entry point from component "cba5a782-4e93-4336-a265-6480620eae92" (HelloWorldWebPart). Original error: Error loading https://component-id.invalid/cba5a782-4e93-4336-a265-6480620eae92_0.0.1 https://component-id.invalid/cba5a782-4e93-4336-a265-6480620eae92_0.0.1 did not call System.register or AMD define. If loading a global module configure the global name via the meta exports property for script injection support. at Anonymous function (http://contoso/_layouts/15/next/spfx/sp-classic-page-assembly_en-us.js?version=1:507:105789) at q (http://contoso/_layouts/15/next/spfx/sp-classic-page-assembly_en-us.js?version=1:8:2379) at B (http://contoso/_layouts/15/next/spfx/sp-classic-page-assembly_en-us.js?version=1:8:2467) at k (http://contoso/_layouts/15/next/spfx/sp-classic-page-assembly_en-us.js?version=1:8:2289) at L (http://contoso/_layouts/15/next/spfx/sp-classic-page-assembly_en-us.js?version=1:8:1885) at y (http://contoso/_layouts/15/next/spfx/sp-classic-page-assembly_en-us.js?version=1:8:570)
Steps to Reproduce
- Launch Yeoman generator using yo (at)microsoft/sharepoint
- When prompted for a baseline package, select SharePoint 2016 onwards, including SharePoint Online
- Accept all other defaults. The issue happens with any framework.
- Once Yeoman complete, test web part on workbench using gulp serve. The web part should work successfully.
- Create a CDN location for your package assets.
- Add the path to your CDN by updating the cdnBasePath property in config/write-manifest.json
- Build package for deployment using gulp bundle --ship and gulp package-solution --ship
- Upload content of the dist folder to your CDN library
- Upload the .sppkg file found in the sharepoint/solution folder to your on-premises app catalog
- Add web part to a test site.
I sincerely hope that it is something I did wrong, but I've eliminated every steps where I could have introduced an issue and i still get a bug.
I ran network profiling in Chrome's developer tools and found that the browser is looking for hello-world-web-part_74e94df2a446590a826da7237beeba04.js, but the dist folder only contains hello-world-web-part.js. Renaming the file to match what the browser is looking for fixed the issue. It must be something in the bundling or solution packaging.
I hope this helps?
The hash in file name can be enabled/disabled from the below line in gulpfile.js. build.copyAssets.taskConfig = { excludeHashFromFileNames: true };
Yes, but why would a brand new, out of the (yeoman) big web part not work?
Hi @hugoabernier - can you double check the version of the SP2016 you are using and that the Feature Pack 2 is required for that to be able to support SPFx. Thx.
@VesaJuvonen We're at version 16.0.4690.1000, which includes FP2 -- correct
This is a standard scenario that we have tested creating an out of the box webpart. The error does not repro for us. Due to the nature of it being an on premises solution you will need to engage support to follow up on the issue.
Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues