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

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

No comments

 5,015 total views,  22 views today

When we work on 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?

The root cause of this error is – it is trying to find the gulpfile.js in the project directory but it does not exists. 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 ‘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.
‘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 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
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
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:

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

GitHub Reference:

https://gist.github.com/objarni/2ece180ddb69eb71564e#file-install-gulp-txt

See Also

You may also like the below SharePoint SPFx articles:

Free download SharePoint Online & Office 365 Administration eBook(238 Pages)

Get the PDF eBook from here:


[purchase_link id="0" style="button" color="blue" text="Free Download SharePoint Online & Office 365 Administration"]

 

 
FREE DOWNLOAD

Send download link to:

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