0
votes

The problem description is basically identical to the one answered here but the solution given for that one won't work for me.

I've been running Gulp and XAMPP for over a year on this machine to develop a number of Wordpress sites locally before launch. This problem appeared without apparent warning yesterday and is affecting all my local projects. I didn't update anything that I'm aware of preceding this, although I'm running Windows 10 so it's possible an OS update I wasn't aware of broke things.

The full text of the error in PowerShell:

gulp : The term 'gulp' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + gulp go + ~~~~ + CategoryInfo : ObjectNotFound: (gulp:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException`

Interestingly, cmd.exe gives a different error, which I can't understand at all:

AssertionError [ERR_ASSERTION]: Task function must be specified at Gulp.set [as _setTask] (C:\xampp\htdocs\domainname.com\node_modules\undertaker\lib\set-task.js:10:3) at Gulp.task (C:\xampp\htdocs\domainname.com\node_modules\undertaker\lib\task.js:13:8) at Object. (C:\xampp\htdocs\domainname.com\gulpfile.js:37:6) at Module._compile (internal/modules/cjs/loader.js:1158:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10) at Module.load (internal/modules/cjs/loader.js:1002:32) at Function.Module._load (internal/modules/cjs/loader.js:901:14) at Module.require (internal/modules/cjs/loader.js:1044:19) at require (internal/modules/cjs/helpers.js:77:18) at execute (C:\Users\username\AppData\Roaming\npm\node_modules\gulp\node_modules\gulp-cli\lib\versioned\^4.0.0\index.js:36:18) { generatedMessage: false, code: 'ERR_ASSERTION', actual: false, expected: true, operator: '==' }`

EDIT: I got the above error when Gulp was installed globally. After uninstalling it globally (still installed locally to this project) I get the more expected error:

'gulp' is not recognized as an internal or external command, operable program or batch file.`

/END EDIT

NPM commands are not affected, and I've tried various combinations of uninstalling, reinstalling, and updating gulp, including globally, all to no avail. I have tried updating node.js, also to no effect.

Although I've been using Gulp/NPM/Node for some time, I am not a superuser and my command line skills are rudimentary, so there may be something I've missed in my troubleshooting. All thoughts and possibilities will be gratefully accepted, as I'm in a somewhat desperate position and unable to do almost any development work because of this problem.

1
You'll have to run it from a cmd line not powershell. It looks like you may have recently upgraded gulp to v4, which is different than v3.. See here for more.. Can you look in your package.json to see which version of gulp you are on?Matt Oestreich
@Matt Oestreich I was running 3.9.1 when the problem occurred; I updated to 4.0.2 while trying to fix it. I'm diving into your link now, though! Can you clarify what exactly I need to run from cmd line?jessefivey
You don't need to run anything differently from the command line. Gulp changed how you write tasks stackoverflow.com/a/52585938/10431732Matt Oestreich
@Matt Oestreich Thanks for the links! I now understand the changes between Gulp 3 and Gulp 4 and how I will need to edit my gulpfile(s). However, the errors that I am getting aren't about my tasks, but about the 'gulp' command itself. Unless I install Gulp globally (which I hadn't before today) the command line fails to recognize 'gulp' well before it gets to my task. I'm exploring whether I can change my setup to use global packages but that's more of a sidestep/workaround for the problem than a solution, so if you had ideas about that I'd be grateful!jessefivey
You cannot run gulp from powershell... if you're in powershell, run cmd first then gulp... clearly, your issues does have to do with how you are writing your gulp file... it's clear as day... AssertionError [ERR_ASSERTION]: Task function must be specified google that.Matt Oestreich

1 Answers

0
votes

Still no idea why or how this happened but for anyone looking for the same answer, I got my setup back to mostly working order by running npm install gulp -g followed by npm install gulp-cli -g --force. It was necessary to force it for some reason because otherwise it couldn't write to the directory? YMMV. Finally, I uninstalled Gulp locally and then reinstalled it. Absolutely no clue why this step was necessary.

Long story short, local/project-level Gulp stopped working, but global Gulp (installed to AppData/Roaming/etc. in Windows 10) works fine and uses your local gulpfile when run locally as normal. I had to rewrite my gulpfiles to use the new task format, but currently everything is working as expected except Browser Sync, which is on me and matter for a different question.

Big thanks to Matt Oestreich in the comments above, whose help was invaluable in solving this. One correction though, it is possible to run Gulp from PowerShell and this was not part of my problem.