- Node.js LTS version 18.x (do not use Node 20+)
- Git
- Visual Studio Code
- SharePoint Framework Yeoman generator
- Admin access to SharePoint tenant
# Install Node.js LTS (if not already installed)
# Download from https://nodejs.org/
# Verify Node version
node -v # Should show v18.x.x
# Install required global dependencies
npm install -g gulp-cli yo @microsoft/generator-sharepoint
# Clone the GitHub repository
git clone [repository-url]
cd [repository-name]
# Install project dependencies
npm install
Create/update the following files in the project root:
// config/serve.json
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/spfx-serve.schema.json",
"port": 4321,
"https": true,
"initialPage": "https://[your-tenant].sharepoint.com/_layouts/15/workbench.aspx"
}
// gulpfile.js adjustments (if needed)
build.configureWebpack.mergeConfig({
additionalConfiguration: (generatedConfiguration) => {
generatedConfiguration.module.rules.push({
test: /\.m?js$/,
resolve: {
fullySpecified: false
}
});
return generatedConfiguration;
}
});
// config/package-solution.json
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": {
"name": "your-solution-name",
"id": "your-solution-id",
"version": "1.0.0.0",
"includeClientSideAssets": true,
"skipFeatureDeployment": true,
"isDomainIsolated": false
}
}
# Clean previous builds
gulp clean
# Bundle the solution
gulp bundle --ship
# Package the solution
gulp package-solution --ship
This creates a .sppkg file in the sharepoint/solution folder.
- Navigate to your tenant's App Catalog (/_catalog/appcatalog)
- Upload the .sppkg file
- Check "Make this solution available to all sites in the organization"
- Click "Deploy"
- Go to your SharePoint site
- Click Settings (gear icon) → Add an app
- Find your web part in the list
- Click "Add"
- Edit the page
- Click + to add a new web part
- Find your web part in the list
- Configure the web part properties
- Node Version Conflicts
# Check Node version
node -v
# Use nvm to switch versions if needed
nvm install 18
nvm use 18
- Package Dependencies Issues
# Clear npm cache
npm cache clean --force
# Delete node_modules and package-lock.json
rm -rf node_modules package-lock.json
# Reinstall dependencies
npm install
- Build Errors
# Run with verbose logging
gulp bundle --ship --verbose
# Check for TypeScript errors
tsc --noEmit
- Deployment Issues
# Connect to SharePoint Online
Connect-PnPOnline -Url https://[tenant].sharepoint.com/sites/[site] -Interactive
# Check app status
Get-PnPApp -Identity [app-id]
# Force app upgrade if needed
Update-PnPApp -Identity [app-id] -Scope Site
- Version Management
- Always increment version numbers in package-solution.json
- Use semantic versioning (MAJOR.MINOR.PATCH)
- Keep a changelog
- Performance Optimization
- Implement lazy loading for non-critical components
- Use webpack bundle analyzer to identify large dependencies
- Implement caching strategies for API calls
- Error Handling
try {
// Your code
} catch (error) {
console.error('Error in web part:', error);
this.context.statusRenderer.renderError(
this.domElement,
'An error occurred while rendering the web part.'
);
}
- Security Considerations
- Use PnP secure store for sensitive data
- Implement proper permission checks
- Validate all user inputs
- Verify all features work as expected
- Test with different permission levels
- Check browser console for errors
- Check initial load time
- Verify network requests
- Monitor memory usage
Test in:
- Edge (Latest)
- Chrome (Latest)
- Firefox (Latest)
- Safari (Latest)
- Documentation Links
- Useful Commands
# Development server
gulp serve
# Clean build
gulp clean
gulp bundle --ship
gulp package-solution --ship
# Update dependencies
npm outdated
npm update
Remember to always test in a development environment first before deploying to production.