Gatsby run problem -'gatsby' is not recognized as an internal or external command, operable program or batch file

Viewed 6358

Its odd as it did work now I cannot run Gatsby commands in VS code, CMD or Powershell

If I install it every thing works and I get the "success" bit and a list of useful commands. This may have happened after I experimented with Hugo. I get the feeling it might be my path???

I do get this error when I run

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.

Any ideas, I have tried to clear NPM cache with no luck

Thanks

5 Answers

To answer the question, these are the warning which we get because some of our packages are outdated.

You can always identify the outdated versions and update them, but it will not be a harm, as it is just a warning.

npm outdated // to know all the outdated packages.
npm install --save core-js@^3 // update the core-js 

But if you are getting gatsby recognized as an internal or external command error, then execute,

$ npm install -g gatsby-cli

and if you want a fresh installation, then

$ npm uninstall gatsby-cli
$ npm install -g gatsby-cli

If you are on Windows Gatsby most likely gets installed to:

C:\Users\yourUserName\AppData\Roaming\npm

make sure that the path above is in your environment variables under path

if you are getting that error then run the below code in the terminal of your vs code

npm start

I faced the same problem. There is a simple two step process:

  1. add the node_modules path to the system variables path in environment variables. run npm config get prefix -g to get your node_modules path. ex: my node_module path is C:\Users\mrad271895\AppData\Roaming\npm
  2. Install the latest node.js LTS as Gatsby requires node version 12 or above.
  3. Restart all the terminals once above steps are done and try gatsby -v. You will get your gatsby-cli version. if you get this gatsby is installed and is running successfully

Apart from all of the solutions mentioned above I just want to add:-

  1. After doing these steps

    $ npm uninstall gatsby-cli $ npm install -g gatsby-cli

  2. Go to C:\usr\local and copy the path (you could probably see the gatsby files there)

  3. Set the path in the environment variables and if powershell/cmd is open, close it then again open it and type gatsby --version and then you will find the gatsby version indicating that gatsby has been installed.

Related