Gatsby: 'gatsby' is not recognized as an internal or external command

Created on 18 Oct 2017  路  8Comments  路  Source: gatsbyjs/gatsby

Operating System: Windows 10 Pro
Version: 10.0.15063 Build 15063
Command Prompt: ConEmu
Startup Tasks:

set PATH=%ConEmuBaseDir%\Scripts;%PATH%
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat"
"C:\Program Files\nodejs\nodevars.bat"

After installing, and re-installing (npm i gatsby-cli@latest -g), I still can't execute gatsby commands outside of the Node.js command prompt on my box.

What did I do wrong?

question or discussion

Most helpful comment

I just tried with Vue and I got the same behavior.

Editing my admin account's path variable to include the npm path solved the problem.

  1. Click Start, then type "environment" (without quotes).
  2. Click Edit the system environment variables.
  3. Enter admin credentials.
  4. In the user variables for my-admin-account, select Path and click Edit.
  5. Click New, and enter C:UsersAppDataRoamingnpm.
  6. Confirm and close all dialogs.
  7. Restart the Windows command prompt as admin. Gatsby should work now.

Note that I clicked to edit system variables in step 2 so that I would be prompted for my admin creds. If the OP doesn't have to use an admin account, then he can click Edit environment variables for your account instead.

For me the issue is resolved. And thanks @pieh for that tip about the npm path, which has resolved my other similar node issues as well! Perhaps @consultwithmike could comment on whether this solution works for him. If so, it is an npm/node issue and not in Gatsby's purview IMO as well.

All 8 comments

Same OS and symptom here. I can run gatsby from the node.js prompt but not the cmd prompt or PowerShell for example.

Same issue here.

Can you use any other npm global packages? Can you check if after using echo %PATH% in command prompt you see there path to npm? (should be something like C:\Users\<username>\AppData\Roaming\npm

The path to npm is there in both command windows if I run as standard user. But gatsby and seemingly most other node applications are blocked by group policy unless I run the prompt as admin. As admin, the path to npm shows up in the node prompt (pointing to my usersadmin-account... folder), but not in the Windows command prompt.

I'm not sure if this something gatsby can fix? This seem more of npm issue here especially that this problem exists in other node applications :/

I just tried with Vue and I got the same behavior.

Editing my admin account's path variable to include the npm path solved the problem.

  1. Click Start, then type "environment" (without quotes).
  2. Click Edit the system environment variables.
  3. Enter admin credentials.
  4. In the user variables for my-admin-account, select Path and click Edit.
  5. Click New, and enter C:UsersAppDataRoamingnpm.
  6. Confirm and close all dialogs.
  7. Restart the Windows command prompt as admin. Gatsby should work now.

Note that I clicked to edit system variables in step 2 so that I would be prompted for my admin creds. If the OP doesn't have to use an admin account, then he can click Edit environment variables for your account instead.

For me the issue is resolved. And thanks @pieh for that tip about the npm path, which has resolved my other similar node issues as well! Perhaps @consultwithmike could comment on whether this solution works for him. If so, it is an npm/node issue and not in Gatsby's purview IMO as well.

I'll close this as this issue is not really gatsby related.

This issue is not Gatsby related.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

signalwerk picture signalwerk  路  3Comments

magicly picture magicly  路  3Comments

dustinhorton picture dustinhorton  路  3Comments

3CordGuy picture 3CordGuy  路  3Comments

Oppenheimer1 picture Oppenheimer1  路  3Comments