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 #20163

Closed
ghost opened this issue Dec 17, 2019 · 17 comments
Closed

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

ghost opened this issue Dec 17, 2019 · 17 comments
Labels
stale? Issue that may be closed soon due to the original author not responding any more. status: needs more info Needs triaging and reproducible examples or more information to be resolved

Comments

@ghost
Copy link

ghost commented Dec 17, 2019

I created a new gatsby project after installing Node, NPM, and Gatsby CLI. The project was working fine. I tried to deploy on Netlify which was unsuccessful as it couldn't find gatsby-plugin-styled-components and also threw Error: Build script returned non-zero exit code:1 I found on discussion forums to delete yarn.lock and package-lock.json file, I removed these files from my local machine and git repository. The project stopped working on the local machine as well and threw some errors so update npm, gatsby and gatsby-cli but now my machine doesn't recognize gatsby commands. How should I uninstall everything NPM, gatsby, gatsby-cli and start with the fresh installation?

My system details:

npm version 6.12.1
node version v12.13.1
npm view gatsby version = 2.18.12
npm gatsby -v = 6.12.1
npm gatsby-cli -v = 6.12.1

If try below command on cmd win 10, I get the following error:

gatsby -v = 'gatsby' is not recognized as an internal or external command,
operable program or batch file.

Please guide how to run my gatsby project.

@LekoArts LekoArts added the status: needs more info Needs triaging and reproducible examples or more information to be resolved label Dec 17, 2019
@LekoArts
Copy link
Contributor

Hi!

Can you share your repository so that other people can try it on their machines? I'd suggest deleting node_modules and your *.lock files, then rerun npm install. The last error message suggests that gatsby-cli isn't installed globally on your computer.

@monizb
Copy link
Contributor

monizb commented Dec 17, 2019

Hey!

To start fresh installation i recommend you the following steps to delete the existing files:
$ npm uninstall gatsby-cli

To reinstall:
npm install -g gatsby-cli

I think uninstalling npm would be pretty useless as i don’t think there is any problem with that.

@ghost
Copy link
Author

ghost commented Dec 17, 2019

Do I need to delete the entire node_modules folder and yarn.lock and package-lock.json files as well?

I tried with npm run start command and I receive these errors now:

https://prnt.sc/qc3e7s
https://prnt.sc/qc303p

@ghost
Copy link
Author

ghost commented Dec 18, 2019

Hey!

To start fresh installation i recommend you the following steps to delete the existing files:
$ npm uninstall gatsby-cli

To reinstall:
npm install -g gatsby-cli

I think uninstalling npm would be pretty useless as i don’t think there is any problem with that.

I tried this process but still can't run gatsby commands.

@ghost
Copy link
Author

ghost commented Dec 18, 2019

Environment:

System:
OS: Windows 10 10.0.18362
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Binaries:
Node: 12.13.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.19.2 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.13.4 - C:\Program Files\nodejs\npm.CMD
Languages:
Python: 2.7.17 - C:\Python27\python.EXE
Browsers:
Edge: 44.18362.449.0
npmPackages:
gatsby: ^2.18.12 => 2.18.12
gatsby-image: ^2.2.36 => 2.2.36
gatsby-plugin-manifest: ^2.2.33 => 2.2.33
gatsby-plugin-offline: ^3.0.27 => 3.0.29
gatsby-plugin-page-transitions: ^1.0.8 => 1.0.8
gatsby-plugin-prefetch-google-fonts: ^1.4.3 => 1.4.3
gatsby-plugin-react-helmet: ^3.1.18 => 3.1.18
gatsby-plugin-sharp: ^2.3.8 => 2.3.8
gatsby-plugin-styled-components: ^3.1.16 => 3.1.16
gatsby-source-filesystem: ^2.1.40 => 2.1.42
gatsby-source-graphql: ^2.1.28 => 2.1.28
gatsby-source-wordpress: ^3.1.53 => 3.1.53
gatsby-transformer-sharp: ^2.3.9 => 2.3.9

@ghost
Copy link
Author

ghost commented Dec 18, 2019

Hi!

Can you share your repository so that other people can try it on their machines? I'd suggest deleting node_modules and your *.lock files, then rerun npm install. The last error message suggests that gatsby-cli isn't installed globally on your computer.

I tried this but still can't run gatsby commands. I tried to run with "npm run start" and it shows below error:

UNHANDLED REJECTION Cannot create as TypeComposer the following value: Date.

Error: Cannot create as TypeComposer the following value: Date.

  • SchemaComposer.js:365 SchemaComposer.createTempTC
    [expatguideturkey]/[graphql-compose]/lib/SchemaComposer.js:365:11

  • SchemaComposer.js:563 SchemaComposer.addAsComposer
    [expatguideturkey]/[graphql-compose]/lib/SchemaComposer.js:563:27

  • schema-composer.js:35 createSchemaComposer
    [expatguideturkey]/[gatsby]/dist/schema/schema-composer.js:35:18

  • index.js:133 Object.build
    [expatguideturkey]/[gatsby]/dist/schema/index.js:133:26

  • index.js:412 async module.exports
    [expatguideturkey]/[gatsby]/dist/bootstrap/index.js:412:3

  • develop.js:419 async module.exports
    [expatguideturkey]/[gatsby]/dist/commands/develop.js:419:7


Debug Log:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\Program Files\nodejs\node.exe',
1 verbose cli 'C:\Program Files\Git\usr\local\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'start'
1 verbose cli ]
2 info using npm@6.13.4
3 info using node@v12.13.1
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle gatsby-starter-default@0.1.0prestart: gatsby-starter-default@0.1.0
6 info lifecycle gatsby-starter-default@0.1.0
start: gatsby-starter-default@0.1.0
7 verbose lifecycle gatsby-starter-default@0.1.0start: unsafe-perm in lifecycle true
8 verbose lifecycle gatsby-starter-default@0.1.0
start: PATH: C:\Program Files\Git\usr\local\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Windows\System32\gatsby-projects\expatguideturkey\node_modules.bin;C:\Python27;C:\Python27\Scripts;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Cmder;C:\Program Files (x86)\Gow\bin;C:\Gradle\gradle-5.6.1\bin;C:\Program Files\nodejs;C:\ProgramData\chocolatey\bin;C:\Program Files (x86)\Yarn\bin;C:\Program Files\Git\cmd;C:\Program Files\PuTTY;C:\Users\Emma\AppData\Local\Microsoft\WindowsApps;C:\Users\Emma\AppData\Local\Programs\Micr
9 verbose lifecycle gatsby-starter-default@0.1.0start: CWD: C:\Windows\System32\gatsby-projects\expatguideturkey
10 silly lifecycle gatsby-starter-default@0.1.0
start: Args: [ '/d /s /c', 'npm run develop' ]
11 silly lifecycle gatsby-starter-default@0.1.0start: Returned: code: 1 signal: null
12 info lifecycle gatsby-starter-default@0.1.0
start: Failed to exec start script
13 verbose stack Error: gatsby-starter-default@0.1.0 start: npm run develop
13 verbose stack Exit status 1
13 verbose stack at EventEmitter. (C:\Program Files\Git\usr\local\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:210:5)
13 verbose stack at ChildProcess. (C:\Program Files\Git\usr\local\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:210:5)
13 verbose stack at maybeClose (internal/child_process.js:1021:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
14 verbose pkgid gatsby-starter-default@0.1.0
15 verbose cwd C:\Windows\System32\gatsby-projects\expatguideturkey
16 verbose Windows_NT 10.0.18362
17 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\Git\usr\local\node_modules\npm\bin\npm-cli.js" "run" "start"
18 verbose node v12.13.1
19 verbose npm v6.13.4
20 error code ELIFECYCLE
21 error errno 1
22 error gatsby-starter-default@0.1.0 start: npm run develop
22 error Exit status 1
23 error Failed at the gatsby-starter-default@0.1.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

@github-actions
Copy link

github-actions bot commented Jan 7, 2020

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Jan 7, 2020
@sidharthachatterjee
Copy link
Contributor

@amreshabux Did you manage to get this up and running? The error messages suggest that you don't have gatsby-cli globally installed.

Running npm i -g gatsby-cli should fix this for you. In case it doesn't, please reopen and comment with more some info. Thanks!

@ghost
Copy link

ghost commented Jan 16, 2020

@amreshabux Did you manage to get this up and running? The error messages suggest that you don't have gatsby-cli globally installed.

Running npm i -g gatsby-cli should fix this for you. In case it doesn't, please reopen and comment with more some info. Thanks!

yes thanks a lot. The issue is fixed now.

@anuraggharat
Copy link

Plz tell me how did you solve this error? I am facing the same issue.

@kearfy
Copy link

kearfy commented Mar 16, 2020

For everyone experiencing this issue on windows, make sure you have got "C:\Users\mtdev.MICHA-TECLAST\AppData\Roaming\npm" and git added to the system's PATH environment variable. after adding it and reopening my command prompt, it all works fine again.

@marketingsolution
Copy link

Hi I am new with gatsby and programming. Can you help me with that too? I thing I have simmilar case when I try tu uninstall I've got this info:
$ npm uninstall gatsby-cli
npm WARN admin@1.0.0 No description
npm WARN admin@1.0.0 No repository field.

audited 1 package in 1.448s

1 package is looking for funding
run npm fund for details

found 0 vulnerabilities

and after that when I try to install
$ npm install -g gatsby-cli
npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
C:\Program Files\Git\user\local\gatsby -> C:\Program Files\Git\user\local\node_modules\gatsby-cli\cli.js

gatsby-cli@2.12.62 postinstall C:\Program Files\Git\user\local\node_modules\gatsby-cli
node scripts/postinstall.js

Success!

Welcome to the Gatsby CLI! Please visit https://www.gatsbyjs.org/docs/gatsby-cli/ for more information.

npm WARN acorn-dynamic-import@4.0.0 requires a peer of acorn@^6.0.0 but none is installed. You must install peer dependencies yourself.

  • gatsby-cli@2.12.62
    updated 1 package in 23.004s

@Jeswin17
Copy link

a

yup this works as of July 2020.

@dotcorps
Copy link

https://docs.npmjs.com/try-the-latest-stable-version-of-npm
hint is there on how to make gatsby work on windows

  1. npm config get prefix -g enter this on prompt and see where it is pointing . this where gatsby gets installed when we do npm install -g gatsby-cli
  2. if gatsby is installing on different location nodejs path , simply copy gatsby files and folders and move them to nodejs folder it works

@marketingsolution
Copy link

I got something like this:
$ npm install npm@latest
npm WARN saveError ENOENT: no such file or directory, open 'C:\Program Files\nodejs\package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open 'C:\Program Files\nodejs\package.json'
npm WARN nodejs No description
npm WARN nodejs No repository field.
npm WARN nodejs No README data
npm WARN nodejs No license field.

  • npm@6.14.7
    added 16 packages from 2 contributors, removed 17 packages, updated 19 packages and audited 434 packages in 11.243s

2 packages are looking for funding
run npm fund for details

found 0 vulnerabilities

@marketingsolution
Copy link

and the path is:
$ npm config get prefix -g
C:\Program Files\Git\user\local

When I try to use this command: npm config set prefix "${APPDATA}/npm" -g
it' changes nothing.

@LuisArmando-TestCoder
Copy link

LuisArmando-TestCoder commented Jan 15, 2021

Well, this is definitely a solution

I was having this problem in my Windows env

Directly placing the path retrieved by the command
npm config get prefix -g
in the environment variable Path within system variables

Reset your CLI and type gatsby -v which should output something like
Gatsby CLI version: x.y.z

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale? Issue that may be closed soon due to the original author not responding any more. status: needs more info Needs triaging and reproducible examples or more information to be resolved
Projects
None yet
Development

No branches or pull requests

9 participants