Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'gatsby' is not recognized as an internal or external command #2509

Closed
consultwithmike opened this issue Oct 18, 2017 · 10 comments
Closed

'gatsby' is not recognized as an internal or external command #2509

consultwithmike opened this issue Oct 18, 2017 · 10 comments
Labels
type: question or discussion Issue discussing or asking a question about Gatsby

Comments

@consultwithmike
Copy link

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?

@twhiteaker
Copy link
Contributor

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

@thebetterjort
Copy link

Same issue here.

@pieh
Copy link
Contributor

pieh commented Apr 26, 2018

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

@m-allanson m-allanson added the type: question or discussion Issue discussing or asking a question about Gatsby label Apr 26, 2018
@twhiteaker
Copy link
Contributor

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 users\admin-account... folder), but not in the Windows command prompt.

@pieh
Copy link
Contributor

pieh commented Apr 26, 2018

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 :/

@twhiteaker
Copy link
Contributor

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:\Users<your admin username>\AppData\Roaming\npm.
  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.

@pieh
Copy link
Contributor

pieh commented Apr 26, 2018

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

@oluwadamilola
Copy link

This issue is not Gatsby related.

@bobgravity1
Copy link

it is 100% windows 10 and gatsby related. so closing this is silly

@Daycross
Copy link

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:\Users<your admin username>\AppData\Roaming\npm.

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.

Thanks, it's solved to me <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question or discussion Issue discussing or asking a question about Gatsby
Projects
None yet
Development

No branches or pull requests

8 participants