Forum Discussion
pnp-modern-search does not work in the local SharePoint workbench
Version used
4.9.0 (SPFx 1.15.0)
Describe the bug
The solution works correctly when deployed using the .sppkg package in SharePoint Online, but it does not work in the local SharePoint workbench.
There are two related issues:
- When running gulp serve, the build/runtime reports an error related to
microsoft/sp-webpart-workbench/lib/api/, suggesting a failure in loading or resolving the local workbench API module.
- When adding the web part to the local workbench page, the web part fails to render with the following error:
Error: Cannot find module './15.js'
The second error appears to be related to a missing or incorrectly resolved chunk/module during bundle loading.
The issue only occurs in the local workbench. The deployed .sppkg solution in SharePoint Online works correctly.
Node.js version: 16.8.0 (compatible with SPFx 1.15.0).
Dependencies installed via npm install without errors.
To Reproduce
- Clone the repository
- Run npm install
- Run gulp serve
- Open the local SharePoint workbench
- Add the web part to the page
- Observe:
- Error during gulp serve related to microsoft/sp-webpart-workbench/lib/api/
- Web part fails to load with Cannot find module './15.js'
Expected behavior
The web part should load and render correctly in the local workbench without module resolution errors.
Desktop :
Browser: Chrome
Node.js: 16.8.0
SPFx: 1.15.0
1 Reply
- ScrollZSilvaCopper Contributor
Hi,
Since the .sppkg package works correctly in SharePoint Online, the issue is likely related specifically to the local workbench environment or bundle/chunk resolution during local serving.
A few things you can try:
- Delete and reinstall dependencies completely:rm -rf node_modules rm package-lock.json npm install
- Clear old build artifacts:gulp clean gulp build gulp bundle gulp serve
- Verify that the local workbench version is compatible with SPFx 1.15.0
- Some older/local workbench APIs can behave inconsistently with newer dependency versions
- The Cannot find module './15.js' error often indicates chunk loading or webpack bundling issues
- Check if dynamic imports or lazy-loaded modules are being generated incorrectly
- Also verify webpack/package version compatibility
- Try testing with a minimal/default web part in the same local workbench environment to confirm whether the issue is specific to pnp-modern-search or the local setup itself
Since SharePoint Online deployment works correctly, this does not appear to be a packaging issue, but rather a local development/runtime resolution problem.
Let me know if you find anything different after rebuilding the environment 👍