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

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:

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

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.

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.

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
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.

See also  SharePoint Framework - Fluent UI React ChoiceGroup (Radio Button) and Checkbox Example

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:

  • >