gatsby: "Gatsby: command not found" on trying to run Gatsby command after installing npm install --global gatsby-cli
On referring to the docs on gatsby page, Was not able to run the gatsby command for the new static site.
My environment details are as follows: npm -v : 3.10.10 node -v : v6.14.1. Operating System: Linux 4.4.0-119-generic (ubuntu 16.04) These are the file structure on installing gastby cli
-- gatsby-cli@1.1.50
+-- core-js@2.5.5
+-- update-notifier@2.4.0
| +-- configstore@3.1.2
| +-- is-ci@1.1.0
| | `-- ci-info@1.1.3
| `-- latest-version@3.1.0
| `-- package-json@4.0.1
| +-- got@6.7.1
| | `-- lowercase-keys@1.0.1
| `-- registry-auth-token@3.3.2
| `-- rc@1.2.6
`-- yurnalist@0.2.1
+-- inquirer@3.3.0
| +-- ansi-escapes@3.1.0
| `-- external-editor@2.2.0
| `-- iconv-lite@0.4.21
| `-- safer-buffer@2.1.2
`-- invariant@2.2.4
On entering the new create command : gatsby new gatsby-site i get an error saying :gatsby: command not found
What am i doing wrong here.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 5
- Comments: 46 (7 by maintainers)
@bfeldman89 Here are the steps I took that resolved the issue for me as well based on @pereiraryan’s steps.
Step 1 - Set Config
If you are using
nvm, you want to usesince
nvmis not compatible with the npm config “prefix” option.Otherwise, if you don’t use
nvm, you can just runStep 2 - Install Gatsby
Install
gatsbyglobally withnpmStep 3 - Verify Installation
Verify gatsby is installed correctly by listing all the packages you have installed globally at the first level (so not dependencies)
which should output something like this
Step 4 - Huzzah
Success! Now you can use
gatsbyin all its loveliness.After some trial & error, I finally found the solution. You have to change the
“npm config prefix” like so: npm config set prefix /usr/localpreviously It appeared that it installed “gatsby-cli” in my local folder that is /Users/YOURUSERNAME/node_modules and not in the global NPM folder.and then when I re-ran npm root -g, I got the correct root folder: /usr/local/lib/node_modules 👍
Does
npm -g ls --depth=0listgatsby-clias being installed?GATSBY FUCKING SUKS! you install the cli and then it fducking doesnt find
gatsbycommand!!???@mcstean
sudo chmod 755 /usr/local/libperhaps?I am having the same problem. I have Windows 10 OS , the prefix is prefix=/usr/local after running command ‘gatsby --version’ it says '‘gatsby’ cannot be recognized as internal or external command. I installed gatsby cli successfully and when I run command -g ls --depth=0 it shows ±- gatsby-cli@2.8.10 `-- npm@6.13.0
what to do now ?
Hello @jamo for this moment all works fine for me 😄
i have follow the instructions you mentionned and outpout is like below , so i think i’m ok ? 😃 ( sorry for my bad english talk ):
sudo chmod 755 /usr/local/libthensudo npm i -g gatsby-clidid the trick for me. Not sure if the chmod is required.This worked great for me but I had to manually go into the npmrc file because my path has a space between the file. So if anybody else has the issue where their npm breaks because of this, try the following.
I’m seeing this as well (“command not found: gatsby” upon running
gatsby --versionafternpm install --global gatsby. My other globally installed binaries (grunt and node-reveal) work for me as expected.OS X here, with npm 6.4.1 and 11.3.0. Node is installed via homebrew, so my value for prefix is
/usr/local/Cellar/node/11.3.0_1