no gulpfile found error in spfx

In this SPFx tutorial, we will discuss how to fix an error, no gulpfile found spfx. The error comes when you run the gulp serve command to run an SPFx client side web part.

no gulpfile found spfx

If you follow the MSDN article to set up your SPFx development environment, then you might not get this issue. But if you still getting the error, no gulpfile found while running the gulp trust-dev-cert or gulp serve then follow the below solution.

If you are new to SPFx development, I have written a complete article on how to set up a development environment for SPFx and also create your first SPFx client-side web part.

When you start developing an SPFx web part, after running the yo @microsoft/sharepoint command, you might get the no gulpfile found error while running any of the below commands:

  • gulp trust-dev-cert
  • gulp build
  • gulp serve

The error you will get, when the gulpfile.js will not be found in the project directory.

To fix the issue, in the same directory, you can run the following command:

npm install touch-cli -g (Run if you never installed touch-cli in your system)

touch gulpfile.js (Then run this command)

Once you run the command, we need to add the default task in the gulpfile.js else you will get the below error:

Task ‘default’ is not in your gulpfile – Please check the documentation for proper gulpfile formatting.

To add a default task in the gulpfile.js file, open the file in visual studio code (even you can open in a notepad file) and then add the below code:

var gulp = require('gulp');
gulp.task('default', function() {
    //Here is the code for the default task

Then you run the gulp serve command and you will not get the no gulpfile found error in your SPFx project.

no gulpfile found error

Apart from this you can also try the following solutions:

Once you get the error, you can run the below command:

npm install --save-dev gulp

Apart from that also, if you want, you can install the particular gulp version in your system like:

npm install - gulp@3.9.0

And you can run the below command to check the gulp version.

gulp -v

You might like the following SPFx tutorials:

This is how we can fix no gulp file found error in spfx.

  • no gulpfile found spfx
  • no gulpfile found gulp serve
  • no gulpfile found error
  • no gulpfile found visual studio code
  • no gulpfile found gulp trust-dev-cert