In this SPFx tutorial, I will explain how to fix the error, cannot find module ‘@microsoft/sp-build-web’ that comes while working with SharePoint Framework.
cannot find module ‘@microsoft/sp-build-web’
I got this error while running the below command while developing a SharePoint client side web part using SPFx.
gulp trust-dev-cert
It gave the error message as: cannot find module ‘@microsoft/sp-build-web’. See the screenshot below:

Let us see how to fix the above error:
To solve this SharePoint Framework error, I ran the command “npm install @microsoft/sp-build-web@1.6.0” in the nodejs command prompt. The command was successfully executed, and the problem was solved.

If the above solutions did not work, try the below solutions which may work for you.
gulp trust-dev-cert error: cannot find module ‘@microsoft/sp-build-web’
Another important thing you can check which version of NodeJS you have installed, It should be Install NodeJS v8.11.4. This is the version which is supported. Do not install the latest version of NodeJS unless communicated from SPFx team.
If the issue still did not resolve, you can try the below solution which was suggested by Prabhu.
Run the below command:
npm i
Another solution you can try, run the below command:
npm install --save-dev
or
npm install --save
The difference between –save and –save-dev is, –save-dev is used to save the package for development purposes only, and –save is used to save the package for the application.
If the above solution does not work, you can try the below command.
To resolve Error: Cannot find module ‘@microsoft/sp-build-web’, you can also try the solution below.
npm install --save-dev '@microsoft/sp-build-web'
Once run the command, you can delete your existing old web part folder and recreate everything using Yeoman.
I hope now you will be able to fix the error cannot find module ‘@microsoft/sp-build-web’ in SharePoint Framework.
You may also like:
- Display SharePoint list items using SPFx
- How to Configure Web Part Icon in SPFx
- SharePoint Framework CRUD Operations using React
- [spfx-serve] The api entry could not be loaded: node_modules/@microsoft/sp-webpart-workbench/lib/api/ in SharePoint Framework

Hey! I’m Bijay Kumar, founder of SPGuides.com and a Microsoft Business Applications MVP (Power Automate, Power Apps). I launched this site in 2020 because I truly enjoy working with SharePoint, Power Platform, and SharePoint Framework (SPFx), and wanted to share that passion through step-by-step tutorials, guides, and training videos. My mission is to help you learn these technologies so you can utilize SharePoint, enhance productivity, and potentially build business solutions along the way.
Thank you so much, it saved my day!