command not found: gulp

[Disclaimer] This article is just for my personal reference as I tend to quickly forget things…

So I cloned a project:

➜ Desktop git clone https://github.com/HackerThemes/theme-kit.git

Installed the project dependencies:

➜ theme-kit git:(master) npm i

The project suggested to run gulp watch, issued the command and encountered the first issue:

➜ theme-kit git:(master) ✗ gulp watch

Obviously this also won’t work:

➜ theme-kit git:(master) ✗ gulp -v

Tried to install gulp-cli globally and failed with the following error:

➜ theme-kit git:(master) ✗ npm install gulp-cli -g

So I switched to nvm:

➜ theme-kit git:(master) ✗ export NVM_DIR=”$HOME/.nvm”

And now checking gulp version worked:

➜ theme-kit git:(master) ✗ gulp -v

However, gulp watch was still throwing an error:

➜ theme-kit git:(master) ✗ gulp watch

Okay, so I rebuilt the node-sass as suggested by the error output above:

➜ theme-kit git:(master) ✗ npm rebuild node-sass

So finally, I was thinking, gulp watch should run, but nope, it threw another error:

➜ theme-kit git:(master) ✗ gulp watch

Now I have no idea what this error is about, looks like something is wrong with gulp.js or something :D

Let’s start beating around the bush, and go through all the uninstall/install trials…

Before uninstalling, checking the gulp version again:

➜ theme-kit git:(master) ✗ gulp -v

Oki, looks like the gulp command works.

Now, globally uninstalled gulp:

➜  theme-kit git:(master) ✗ npm uninstall gulp -g

And uninstall gulp, gulp-cli project dependencies:

➜ theme-kit git:(master) ✗ npm uninstall gulp

Check the version (gulp command shouldn’t work):

➜ theme-kit git:(master) ✗ gulp -v

And guess what, I forgot to uninstall gulp-cli globally…

➜ theme-kit git:(master) ✗ npm install -g gulp-cli

Now pay attention to the above npm ERR! and remove the gulp.1 file:

➜ theme-kit git:(master) ✗ rm /Users/sam/.nvm/versions/node/v9.8.0/share/man/man1/gulp.1

Finally, install gulp-cli globally:

➜ theme-kit git:(master) ✗ npm install -g gulp-cli

And it works…

➜ theme-kit git:(master) ✗ gulp watch

The morals of the story, I should have first checked the official documentation and initially installed the gulp-cli globally… :D

Everything is unknown until it’s known. Self-learner.