SharePoint 2016生产环境移动端JS错误及HTML差异排查求助
Alright, let's tackle this SharePoint 2016 mobile view issue you're facing—you've already done great work narrowing down the key difference between your local and production servers, so let's build on that to get your production environment back on track.
Root Cause Confirmation
The Uncaught TypeError: Cannot read property 'SuiteVersion' of undefined in touchapp.js directly ties to the missing CommonSuiteNavData object on your production server. This server-side injected object carries critical SuiteNav configuration (including SuiteVersion) that the RetrieveMobileSuiteNavData function depends on to render the mobile navigation. Your local server correctly generates this script block and loads mylinks.js (a dependency for SuiteNav), which is why it works without issues.
Why the HTML Differs (Possible Causes)
Even with identical updates applied, SharePoint environments can drift due to configuration or customization differences. Here are the most likely reasons for the missing script block:
- Feature Activation Mismatch: The Suite Navigation feature (or related mobile site features) might be deactivated on your production web application. Features can get turned off accidentally during migrations, updates, or routine configuration changes.
- Custom Master Page Discrepancies: If production uses a customized mobile master page (like a modified
v4.masterorseattle.master), it could be missing the server-side controls that injectCommonSuiteNavDataand referencemylinks.js. Local servers often stick to out-of-the-box master pages unless intentionally modified. - Corrupted Configuration Cache: Production servers tend to run longer without resets, which can lead to a corrupted SharePoint configuration cache. This cache stores server-side rendering settings, and when it's broken, it can cause inconsistent HTML output compared to your regularly refreshed local server.
- CDN Configuration Issues: If you've enabled a Content Delivery Network for SharePoint scripts on production, there might be a misconfiguration blocking
mylinks.jsor preventing theCommonSuiteNavDatablock from being injected correctly. - Mobile View Setting Differences: Double-check that both servers have identical mobile view configurations (Site Settings > Mobile > Mobile Browser View)—a mismatch here could alter how SharePoint renders the mobile page structure.
Step-by-Step Troubleshooting & Fixes
Let's walk through actionable steps to resolve this:
Verify Suite Navigation Feature Activation
- Open Central Administration on production > Application Management > Manage web applications
- Select your production web app, then click Manage Features in the top ribbon
- Ensure Suite Navigation and Mobile Site features are activated. If not, enable them and run an IIS reset on all web front-end servers.
Check Master Page Consistency
- On both servers, go to Site Settings > Master Page and compare the "Mobile Master Page" setting
- If production uses a custom master page, temporarily switch it to the out-of-the-box option (e.g.,
~/_layouts/15/v4.master) and test the mobile view. If the error disappears, your custom master page is missing the necessary SuiteNav controls—you'll need to merge the out-of-the-box master page's SuiteNav-related markup into your custom one.
Clear the SharePoint Configuration Cache
- On each production SharePoint server:
- Stop the SharePoint Timer Service
- Navigate to
C:\ProgramData\Microsoft\SharePoint\Config\<GUID>(pick the folder with the most recent cache files) - Delete all
.xmlfiles exceptcache.ini - Open
cache.ini, set its value to1, then save the file - Restart the SharePoint Timer Service
- Run an IIS reset on all web front-ends after completing this on all servers.
- On each production SharePoint server:
Validate CDN Settings (If Enabled)
- In Central Administration, go to Manage web applications > select your app > General Settings > Content Delivery Network (CDN)
- Verify that
mylinks.jsis included in the allowed script list. If not, add it. - Temporarily disable the CDN to test if the script loads correctly. If the error goes away, adjust your CDN configuration to properly serve SuiteNav-related scripts.
Repair SharePoint Installation (Last Resort)
- If all other steps fail, run a repair on your production SharePoint 2016 installation. Sometimes updates don't apply cleanly, leading to missing or corrupted script files. Use the SharePoint Products Configuration Wizard to initiate a repair, then reapply any necessary updates and reset IIS.
Verification Steps
After applying any fix:
- Clear your browser cache (or use incognito mode) and load the mobile view on production
- View the source of
/_layouts/15/touchapp.aspxto confirm theCommonSuiteNavDatascript block is present andmylinks.jsis being loaded - Open the browser console to check that the
SuiteVersionerror no longer appears
内容的提问来源于stack exchange,提问作者oleg kalenchuk

