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
  • npm install touch-cli -g (Run if you never installed touch-cli in your system)

    touch gulpfile.js (Then run this command)

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

    ——–Even after trying all the steps getting below error————-

    F:SPFxapp-extensions>gulp trust-dev-cert
    [20:42:26] Using gulpfile F:SPFxapp-extensionsgulpfile.js
    [20:42:26] Task never defined: trust-dev-cert
    [20:42:26] To list available tasks, try running: gulp –tasks

    F:SPFxapp-extensions>gulp serve
    [20:42:59] Using gulpfile F:SPFxapp-extensionsgulpfile.js
    [20:42:59] Task never defined: serve
    [20:42:59] To list available tasks, try running: gulp –tasks

    F:SPFxapp-extensions>npm install –save-dev gulp
    npm WARN saveError ENOENT: no such file or directory, open ‘F:SPFxapp-extensionspackage.json’
    npm WARN enoent ENOENT: no such file or directory, open ‘F:SPFxapp-extensionspackage.json’
    npm WARN app-extensions No description
    npm WARN app-extensions No repository field.
    npm WARN app-extensions No README data
    npm WARN app-extensions No license field.
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modulesfsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {“os”:”darwin”,”arch”:”any”} (current: {“os”:”win32″,”arch”:”x64″})

    + gulp@4.0.2
    updated 1 package and audited 503 packages in 4.078s

  • >