I secretly automated my whole job with PowerShell

How to fix “yo : The term ‘yo’ is not recognized as the name of a cmdlet, function, script file, or operable program.” error?

3 min read.

This article explains what to do to get rid of an error that SEEMS simple to fix but might turn out to be elusive, namely, “The term ‘yo’ 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.”

Sounds simple, right? It might be. Read on to find out how I banged my head on the wall with this one!

Problem

When trying to run something like the below:

yo @microsoft/sharepoint

You get this fatal issue:

yo : The term 'yo' 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

What do?

Solution

First we’ll need to make sure we have the right prerequisites installed, and then we make sure the environment variable configuration is ok.

Time needed: 10 minutes

How to fix “The term ‘yo’ is not recognized as the name of a cmdlet, function, script file, or operable program.” on your Windows machine?

  1. Install yo and gulp globally

    A good way to get started is to verify you actually have yo – the yeoman generator – and gulp – the task runner – installed. Because maybe you do have them already, but maybe you don’t.

    This step is conveniently skipped in most tutorials I’ve found, because it’s obvious everyone always has such household names on their machines, right? :)

    npm install -g yo gulp

    Who WOULDN’T have yo installed on their machine, right? Ah, but after this step, you will, too!

  2. Verify your environment variables

    Now you’ll need to make sure you have the npm directory in your Path environment variable.

    You can verify this somewhat like in the screenshot below (this obviously applies to Windows only):



    Note, that in this example I added it to the User variables, but if you installed the tools globally, you could add it to System variables too (those are exposed to all users of your machine – the values are simply concatenated).

  3. Restart your console

    To refresh the environment variables you need to restart your terminal/console/shell session. So whichever flavor of a command line you’re using, restart it now.

  4. Make sure you’re running the right terminal

    Still not working? Ok, let’s get to the non-obvious part.

    yo, gulp and other tools like that rely on their installation path being added to the Path environment variable – but that variable can be set per-user, just like the tools can be installed to a certain user only. So if you’re using multiple user accounts because your tooling requires that, make note of this, too.

    The “-g” flag makes sure that yo & gulp are installed globally (on step 1), but that still doesn’t mean their installation paths would be in each user’s Path variable.

    You can verify which values your current terminal’s Path environment variable has by executing this:

    $env:Path.split(";")

    You might even want to look for the value somewhat like “C:\Users\YourUser\AppData\Roaming\npm” because that’s where yo and gulp should be in.

  5. Restart your machine

    … I’m sorry for being that guy. If all else fails, before buying a mac, you can always try rebooting your machine.

Alright. Hope that was just confusing enough to give you some food for thought, but useful enough to help you overcome the error.

mm
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments