[Solved] cannot find module ‘@microsoft/sp-build-web’ SharePoint Framework (spfx)

In this SharePoint framework tutorial, I will discuss how to resolve error as: cannot find module ‘@microsoft/sp-build-web’ which comes in SharePoint Framework (SPFx).

Here we will discuss various approaches to solve gulp trust-dev-cert error: cannot find module ‘@microsoft/sp-build-web’ SharePoint Framework (spfx) error.

If you are new to the popular SharePoint framework (spfx) development, then you can check out below tutorials where I have explained in detail how to set up your development environment for spfx and how to create your first client web part using spfx.

I have also created a video tutorial for the same:

While I was working on a SharePoint Framework to build a web part for SharePoint Online modern site, I was executing the command as “gulp trust-dev-cert” using SharePoint 2016 Management Shell.  But it throws an error as cannot find module ‘@microsoft/sp-build-web’. You can see that SharePoint Framework error in the below screenshot.

cannot find module '@microsoft/sp-build-web'
cannot find module ‘@microsoft/sp-build-web’

Here we will discuss various solutions to solve the cannot find module ‘@microsoft/sp-build-web’ error.

Cannot find module ‘@microsoft/sp-build-web’ SPFx

To solve this SharePoint Framework error, I ran the command as “npm install @microsoft/sp-build-web@1.6.0” in the SharePoint 2016 Management Shell. Then the command successfully executed and the problem solved.

cannot find module microsoft/sp-build-web spfx
cannot find module microsoft/sp-build-web spfx

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.

gulp error: Cannot find module ‘@microsoft/sp-build-web’

If the issue still did not resolve, you can try the below solution which was suggested by Prabhu.

Run the below command:

npm i

Cannot find module ‘@microsoft/sp-build-web gulp error

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 purpose only and –save is used to save the package for the application.

Error: Cannot find module ‘@microsoft/sp-build-web’

To resolve Error: Cannot find module ‘@microsoft/sp-build-web’, you can try the below solution also.

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.

You can also check the below SharePoint framework tutorials:

I hope this SharePoint Framework article will be helping you to resolve cannot find module ‘@microsoft/sp-build-web’ spfx error.

  • >