[Fixed]: How to fix No gulpfile found in SPFx framework project

[Fixed]: How to fix No gulpfile found error in SPFx framework project

No comments

Loading

No gulpfile found error in SPFx – when we work on the SPFx framework project, after running the “yo @microsoft/sharepoint” command, if we try to run the “Gulp serve” or “Gulp build” command we will get the error “No gulpfile found“.

No gulpfile found in SPFx framework project
No gulpfile found in SPFx framework project

What is the root cause of the “No gulpfile found” error (No gulpfile found error in SPFx)?

The root cause of this error is – it is trying to find the gulpfile.js in the project directory but it does not exist. To fix this error we need to add gulpfile.js to the project directory root by running the command

touch gulpfile.js

Note:

Make sure the ‘touch’ command is installed in the project directory using the npm install touch-cli -g otherwise we will get the below error:

'touch' is not recognized as an internal or external command,
operable program or batch file.
'touch' is not recognized as an internal or external command, operable program or batch file - No gulpfile found error in SPFx
‘touch’ is not recognized as an internal or external command, operable program, or batch file.

Then, run the touch gulpfile.js command.

On a successful run, we should see the command prompt return “Touching gulpfile.js” message.

After adding gulpfile.js in the project directory if we run gulp command, we will get a new error, Task ‘default’ is not in your gulpfile – Please check the documentation for proper gulpfile formatting.

Task 'default' is not in your gulpfile - Please check the documentation for proper gulpfile formatting - No gulpfile found error in SPFx
Task ‘default’ is not in your gulpfile – Please check the documentation for proper gulpfile formatting

The above error means that the gulpfile.js just created by the command does not have a default task in the gulpfile.js. Each gulpfile needs a default task to run when gulp is executed without any arguments. So we should add a default task in the newly created gulpfile by adding the below texts – just open the gulpfile.js in the notepad editor and add the below texts:

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

Now when we run the gulp command we get the below output.

Starting ‘default’…

Default Gulp!

Finished ‘default’ after 509 μs

SPFx - Starting 'default' Default Gulp! Finished 'default' after 509 μs - No gulpfile found error in SPFx
SPFx – Starting ‘default’ Default Gulp! Finished ‘default’ after 509 μs

Now we can say that our gulp process is up and running in our SPFx project directory.

Summary: No gulpfile found error in SPFx

Thus in this troubleshooting technique, how to fix No gulpfile found in SPFx framework project.

Other relevant gulp commands:

npm install gulp-cli -g
npm install gulp -D
touch gulpfile.js
gulp --help

See Also: SPFx Tutorial step by step

You may also like the below SharePoint SPFx articles:

Download SharePoint Online PDF Book

Download SharePoint Online & Office 365 Administration eBook

Buy the premium version of SharePoint Online & Office 365 administration eBook from here:



Buy SharePoint Online & Office 365 Administration eBook


 

Get the free demo PDF eBook from here:

FREE DOWNLOAD

Send download link to:

Subscribe to get exclusive content and recommendations every month. You can unsubscribe anytime.

 

 

About Post Author

Do you have a better solution or question on this topic? Please leave a comment