When I try to install gatsby running npm install 'gatsby-cli -g' , it does not work : when I run 'gatsby --help', it shows:
'bash:gatsby command not found'
I have tried:
1) uninstalling and reinstalling NPM
2) this gitHub solution : https://github.com/gatsbyjs/gatsby/issues/4967
I get a permission error when trying to change npm config set prefix /usr/local
3) Uninstalling and reinstally Gatsby
I'm working on mac (version 10.14.5).
My environment details are as follows:
npm -v : 6.9.0
node -v : v10.16.0
As for permission, I already have an "export PATH=~/.npm-global/bin:$PATH" in a .bash_profile that is in my ~/.npm-global folder (https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally).
What can I do to make it work?
Thanks in advance,
Marie
It does seem like globally installed packages for some reason not work in your environment :/
Here's another article worth to go through: https://medium.com/@jagatjyoti.1si13cs040/npm-g-install-npm-package-not-working-as-desired-why-why-why-19795abf0b59
If this won't help, there is workaround this that you can try - instead of trying to install and use globally installed gatsby-cli
, you can use npx
:
npx gatsby new <directory_name>
npx gatsby develop
npx gatsby build
etc. or add commands to scripts
in package.json
:
"scripts": {
"develop": "gatsby develop",
"build": "gatsby build"
}
and run them with
npm run develop
npm run build
Thank's a lot! I solved my problem :) It was a global installation problem indeed!
I followed the github solution ( #4967) but did a "sudo npm install gatsby-cli -g –"
Oh my God ! It worked ...... Thanks @pieh
I know this is an older post, but being that it showed up first in my search I figured I'd share my solution.
My global packages on my Windows10 (Work machine, I'd much rather a Mac) are set to install at the below path.
/c/Users/{username}/AppData/Roaming/npm
So I added this to my PATH variable and now it finds the installation. You can search for "Environment Variables", click Path and add the path there, or if you're like me and don't have admin rights you can add via Git Bash in Windows like below.
PATH=\$PATH:/c/Users/{username}/AppData/Roaming/npm
You can also create an Bash alias and have it automatically run when you start Git Bash.
This is what worked for me pretty easily:
https://github.com/firebase/firebase-tools/issues/113#issuecomment-301613705
worked for me i was trying in gatsby new
Hello , this command work like a charm for me 👍
i'm on w10 with ubuntu terminal on windows terminal
❯ node -v
v10.23.0
❯ npm -v
6.14.8
" sudo npm install gatsby-cli -g" resolve my problem " "Gatsby: command not found" on trying to run Gatsby command after installing npm install --global gatsby-cli" 👍
for the information , still have this :
❯ npm -g ls --depth=0
/usr/local/lib
└── (empty)
but "gatsby new test-gatsby" work for me
and after run just warnings like below
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
however still working how to resolve this
" npm WARN deprecated @hapi/[email protected]: Switch to 'npm install joi'
npm WARN deprecated @hapi/[email protected]: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/[email protected]: Moved to 'npm install @sideway/address'
npm WARN deprecated @hapi/[email protected]: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/[email protected]: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated highlight.[email protected]: Version no longer supported. Upgrade to @latest
npm WARN deprecated [email protected]: 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.
/usr/bin/gatsby -> /usr/lib/node_modules/gatsby-cli/cli.js[email protected] postinstall /usr/lib/node_modules/gatsby-cli/node_modules/core-js
node -e "try{require('./postinstall')}catch(e){}""
after install gatsby
❯ gatsby --version
Gatsby CLI version: 2.15.0
Most helpful comment
It does seem like globally installed packages for some reason not work in your environment :/
Here's another article worth to go through: https://medium.com/@jagatjyoti.1si13cs040/npm-g-install-npm-package-not-working-as-desired-why-why-why-19795abf0b59
If this won't help, there is workaround this that you can try - instead of trying to install and use globally installed
gatsby-cli
, you can usenpx
:etc. or add commands to
scripts
inpackage.json
:and run them with