jessefivey
jessefivey

Reputation: 1

Gulp stopped working after over a year of working fine, now gives "The term 'gulp' is not recognized" error in command line

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.

Upvotes: 0

Views: 809

Answers (1)

jessefivey
jessefivey

Reputation: 1

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.

Upvotes: 0

Related Questions