Gatsby: "Gatsby: command not found" on trying to run Gatsby command after installing npm install --global gatsby-cli

Created on 13 Apr 2018  ·  45Comments  ·  Source: gatsbyjs/gatsby

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

-- [email protected] 
  +-- [email protected] 
  +-- [email protected] 
  | +-- [email protected] 
  | +-- [email protected]
  | | `-- [email protected] 
  | `-- [email protected]
  |   `-- [email protected]
  |     +-- [email protected]
  |     | `-- [email protected] 
  |     `-- [email protected]
  |       `-- [email protected] 
  `-- [email protected]
    +-- [email protected]
    | +-- [email protected] 
    | `-- [email protected] 
    |   `-- [email protected] 
    |     `-- [email protected] 
    `-- [email protected] 

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.

question or discussion

Most helpful comment

@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 use

npm config delete prefix

since nvm is not compatible with the npm config "prefix" option.

Otherwise, if you don't use nvm, you can just run

npm config set prefix /usr/local

Step 2 - Install Gatsby

Install gatsby globally with npm

npm i -g gatsby-cli

Step 3 - Verify Installation

Verify gatsby is installed correctly by listing all the packages you have installed globally at the first level (so not dependencies)

npm -g ls --depth=0

which should output something like this

/usr/local/lib
└── [email protected]

Step 4 - Huzzah

Success! Now you can use gatsby in all its loveliness.

gatsby new lovely-gatsby-site

All 45 comments

Does npm -g ls --depth=0 list gatsby-cli as being installed?

Yes it shows: [email protected]

is it like gatsby is not supported on linux ?

Lots of people use gatsby on Linux. Check if other npm global binaries work there.

other npm binaries work fine.

Not sure. Perhaps try uninstalling and then reinstalling gatsby-cli. Regardless, this is an npm install problem it sounds like not anything with gatsby. Lots of people are using gatsby on Linux and we regularly test on linux. If you do discover something specific that's causing trouble with your environment, please open a new issue and we'll try to fix it.

i tried cloning the main repo and ran npm install which gave me a npm warning : npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (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"})

fsevents is a Mac dependency so the message is saying npm won't install it.

After some trial & error, I finally found the solution. You have to change the “npm config prefix” like so: npm config set prefix /usr/local
previously 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
:+1:

@pereiraryan Gotcha!

@pereiraryan can you advise what you did more step-by-step? I am having the same issue.

@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 use

npm config delete prefix

since nvm is not compatible with the npm config "prefix" option.

Otherwise, if you don't use nvm, you can just run

npm config set prefix /usr/local

Step 2 - Install Gatsby

Install gatsby globally with npm

npm i -g gatsby-cli

Step 3 - Verify Installation

Verify gatsby is installed correctly by listing all the packages you have installed globally at the first level (so not dependencies)

npm -g ls --depth=0

which should output something like this

/usr/local/lib
└── [email protected]

Step 4 - Huzzah

Success! Now you can use gatsby in all its loveliness.

gatsby new lovely-gatsby-site

This fixed issue for me

Thanks @pereiraryan and @fvcproductions, solved it for me as well.

after typing: npm i -g gatsby-cli I receive an error message and i don't know what to do.
screenshot from 2018-10-18 19-30-03

@mcstean sudo chmod 755 /usr/local/lib perhaps?

This issue in creating a new gatsby site is still appearing, I reinstalled gatsby-cli as global again and over again ...

`gatsby new lovely-gatsby-site
info Creating new site from git: https://github.com/gatsbyjs/gatsby-starter-default.git
Clonage dans 'lovely-gatsby-site'...
remote: Enumerating objects: 969, done.
remote: Total 969 (delta 0), reused 0 (delta 0), pack-reused 969
Réception d'objets: 100% (969/969), 1.25 MiB | 314.00 KiB/s, fait.
Résolution des deltas: 100% (552/552), fait.
success Created starter directory layout
info Installing packages...
yarn install v1.9.4
info No lockfile found.
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] 🔍 Resolving packages...
warning gatsby > eslint > file-entry-cache > flat-cache > [email protected]: CircularJSON is in maintenance only, flatted is its successor.
warning gatsby-plugin-sharp > imagemin-mozjpeg > mozjpeg > bin-build > download > gulp-decompress > [email protected]: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
warning gatsby-plugin-sharp > imagemin-pngquant > pngquant-bin > bin-wrapper > bin-version-check > bin-version > execa > [email protected]: cross-spawn no longer requires a build toolchain, use it instead
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
[4/4] 📃 Building fresh packages...
[-/5] ⠠ waiting...
[2/5] ⠠ sharp
[-/5] ⠠ waiting...
[-/5] ⠠ waiting...
error /Applications/MAMP/htdocs/lovely-gatsby-site/node_modules/sharp: Command failed.
Exit code: 1
Command: (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
Arguments:
Directory: /Applications/MAMP/htdocs/lovely-gatsby-site/node_modules/sharp
Output:
info sharp Detected globally-installed libvips v8.7.0
info sharp Building from source via node-gyp
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info spawn /usr/local/bin/python2
gyp info spawn args [ '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/Applications/MAMP/htdocs/lovely-gatsby-site/node_modules/sharp/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/MiniNaim/.node-gyp/10.8.0/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/Users/MiniNaim/.node-gyp/10.8.0',
gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/Users/MiniNaim/.node-gyp/10.8.0/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/Applications/MAMP/htdocs/lovely-gatsby-site/node_modules/sharp',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.' ]
No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.

gyp: No Xcode or CLT version detected!
gyp ERR! configure error
gyp ERR! stack Error: gyp failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack at ChildProcess.emit (events.js:182:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:238:12)
gyp ERR! System Darwin 18.0.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Applications/MAMP/htdocs/lovely-gatsby-site/node_modules/sharp
gyp ERR! node -v v10.8.0

error Command failed: yarnpkg

Error: Command failed: yarnpkg

  • index.js:236 Promise.all.then.arr
    [lib]/[gatsby-cli]/[execa]/index.js:236:11

  • util.js:16 tryCatcher
    [lib]/[gatsby-cli]/[bluebird]/js/release/util.js:16:23

  • promise.js:512 Promise._settlePromiseFromHandler
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise.js:512:31

  • promise.js:569 Promise._settlePromise
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise.js:569:18

  • promise.js:614 Promise._settlePromise0
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise.js:614:10

  • promise.js:694 Promise._settlePromises
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise.js:694:18

  • promise.js:638 Promise._fulfill
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise.js:638:18

  • promise_array.js:126 PromiseArray._resolve
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise_array.js:126:19

  • promise_array.js:144 PromiseArray._promiseFulfilled
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise_array.js:144:14

  • promise.js:574 Promise._settlePromise
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise.js:574:26

  • promise.js:614 Promise._settlePromise0
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise.js:614:10

  • promise.js:694 Promise._settlePromises
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise.js:694:18

  • async.js:138 _drainQueueStep
    [lib]/[gatsby-cli]/[bluebird]/js/release/async.js:138:12

  • async.js:131 _drainQueue
    [lib]/[gatsby-cli]/[bluebird]/js/release/async.js:131:9

  • async.js:147 Async._drainQueues
    [lib]/[gatsby-cli]/[bluebird]/js/release/async.js:147:5

  • async.js:17 Immediate.Async.drainQueues [as _onImmediate]
    [lib]/[gatsby-cli]/[bluebird]/js/release/async.js:17:14
    `

@Dschau please scan you advise on a book or basic stuffs beginners should master to easily find their way ?
Thanks

@mcstean what exactly are you looking for? Specifically in re: to Gatsby, or more unix-like stuff?

@DSchau More Unix like as I admit also Being a fan.
Is true I really wish to understand how things work to ease the deployment of existing open source application to small businesses.

Oh god, how do I set it back to what it was. I Followed @fvcproductions instructions and the errors i'm getting no matter what I run or in what project i'm in are:

`
Error: EPERM: operation not permitted, mkdir 'C:\Program Files\Git\usr\local'
TypeError: Cannot read property 'get' of undefined
at errorHandler (C:\Program Files\nodejs\node_modulesnpm\lib\utils\error-handler.js:205:18)
at C:\Program Files\nodejs\node_modulesnpm\binnpm-cli.js:78:20
at cb (C:\Program Files\nodejs\node_modulesnpm\libnpm.js:228:22)
at C:\Program Files\nodejs\node_modulesnpm\libnpm.js:266:24
at C:\Program Files\nodejs\node_modulesnpm\lib\config\core.js:83:7
at Array.forEach ()
at C:\Program Files\nodejs\node_modulesnpm\lib\config\core.js:82:13
at f (C:\Program Files\nodejs\node_modulesnpm\node_modules\once\once.js:25:25)
at afterExtras (C:\Program Files\nodejs\node_modulesnpm\lib\config\core.js:173:20)
at C:\Program Files\nodejs\node_modulesnpm\node_modules\mkdirp\index.js:47:53
C:\Program Files\nodejs\node_modulesnpm\lib\utils\error-handler.js:205
if (npm.config.get('json')) {
^

TypeError: Cannot read property 'get' of undefined
at process.errorHandler (C:\Program Files\nodejs\node_modulesnpm\lib\utils\error-handler.js:205:18)
at emitOne (events.js:116:13)
at process.emit (events.js:211:7)
at process._fatalException (bootstrap_node.js:391:26)
Error: EPERM: operation not permitted, mkdir 'C:\Program Files\Git\usr\local'
TypeError: Cannot read property 'get' of undefined
at errorHandler (C:\Program Files\nodejs\node_modulesnpm\lib\utils\error-handler.js:205:18)
at C:\Program Files\nodejs\node_modulesnpm\binnpm-cli.js:78:20
at cb (C:\Program Files\nodejs\node_modulesnpm\libnpm.js:228:22)
at C:\Program Files\nodejs\node_modulesnpm\libnpm.js:266:24
at C:\Program Files\nodejs\node_modulesnpm\lib\config\core.js:83:7
at Array.forEach ()
at C:\Program Files\nodejs\node_modulesnpm\lib\config\core.js:82:13
at f (C:\Program Files\nodejs\node_modulesnpm\node_modules\once\once.js:25:25)
at afterExtras (C:\Program Files\nodejs\node_modulesnpm\lib\config\core.js:173:20)
at C:\Program Files\nodejs\node_modulesnpm\node_modules\mkdirp\index.js:47:53
C:\Program Files\nodejs\node_modulesnpm\lib\utils\error-handler.js:205
if (npm.config.get('json')) {
^

TypeError: Cannot read property 'get' of undefined
at process.errorHandler (C:\Program Files\nodejs\node_modulesnpm\lib\utils\error-handler.js:205:18)
at emitOne (events.js:116:13)
at process.emit (events.js:211:7)
at process._fatalException (bootstrap_node.js:391:26)
`

So even my projects that were working using the normal "create-react-app" dont work.

I'm seeing this as well ("command not found: gatsby" upon running gatsby --version after npm 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

@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 use

npm config delete prefix

since nvm is not compatible with the npm config "prefix" option.

Otherwise, if you don't use nvm, you can just run

npm config set prefix /usr/local

Step 2 - Install Gatsby

Install gatsby globally with npm

npm i -g gatsby-cli

Step 3 - Verify Installation

Verify gatsby is installed correctly by listing all the packages you have installed globally at the first level (so not dependencies)

npm -g ls --depth=0

which should output something like this

/usr/local/lib
└── [email protected]

Step 4 - Huzzah

Success! Now you can use gatsby in all its loveliness.

gatsby new lovely-gatsby-site

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.

  1. Locate your .npmrc file and open it (I just used notepad)
  2. look at your current prefix location. (For me it was prefix=C:/Program Files/Git/usr/local)
  3. If you're looks something like mine with the space between the path folder add the \/ between the files like you would in git.
    ex. prefix=C:/Program\/Files/Git/usr/local

Moved to new machine recently, just installing Gatsby CLI globally should fix this.

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

-- [email protected] 
  +-- [email protected] 
  +-- [email protected] 
  | +-- [email protected] 
  | +-- [email protected]
  | | `-- [email protected] 
  | `-- [email protected]
  |   `-- [email protected]
  |     +-- [email protected]
  |     | `-- [email protected] 
  |     `-- [email protected]
  |       `-- [email protected] 
  `-- [email protected]
    +-- [email protected]
    | +-- [email protected] 
    | `-- [email protected] 
    |   `-- [email protected] 
    |     `-- [email protected] 
    `-- [email protected] 

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.

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

-- [email protected] 
  +-- [email protected] 
  +-- [email protected] 
  | +-- [email protected] 
  | +-- [email protected]
  | | `-- [email protected] 
  | `-- [email protected]
  |   `-- [email protected]
  |     +-- [email protected]
  |     | `-- [email protected] 
  |     `-- [email protected]
  |       `-- [email protected] 
  `-- [email protected]
    +-- [email protected]
    | +-- [email protected] 
    | `-- [email protected] 
    |   `-- [email protected] 
    |     `-- [email protected] 
    `-- [email protected] 

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.

I was also getting same error but my issue has resolved by using cammand with sudo

@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 use

npm config delete prefix

since nvm is not compatible with the npm config "prefix" option.

Otherwise, if you don't use nvm, you can just run

npm config set prefix /usr/local

Step 2 - Install Gatsby

Install gatsby globally with npm

npm i -g gatsby-cli

Step 3 - Verify Installation

Verify gatsby is installed correctly by listing all the packages you have installed globally at the first level (so not dependencies)

npm -g ls --depth=0

which should output something like this

/usr/local/lib
└── [email protected]

Step 4 - Huzzah

Success! Now you can use gatsby in all its loveliness.

gatsby new lovely-gatsby-site

Hello,
I'm having the same issue.

When I run gatsby --version, I get a : -bash: gatsby: command not found.
In the step 3, when I run( npm -g ls --depth=0), I get this result :

/Users/mariequittelier/npm/lib
└── [email protected]

My environment details are as follows:
npm -v : 6.9.0
node -v : v10.16.0

What can I do to make it work?

Thanks in advance,
Marie

after typing: npm i -g gatsby-cli I receive an error message and i don't know what to do.
screenshot from 2018-10-18 19-30-03

sudo chmod 755 /usr/local/lib
then
sudo npm i -g gatsby-cli
did the trick for me. Not sure if the chmod is required.

till step 3 it worked for me but but, after that when I write command gatsby new my-blog ,it says gatsby is not recognized as internal or external command.
Suggest anything I can check ,verify so that it will work.

I'm seeing this as well ("command not found: gatsby" upon running gatsby --version after npm 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

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 +-- [email protected]
`-- [email protected]

what to do now ?
Screenshot (215)

I'm seeing this as well ("command not found: gatsby" upon running gatsby --version after npm 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

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 +-- [email protected]
`-- [email protected]

what to do now ?
Screenshot (215)

I'm having the same issue! It's showing all good but when I run the command it says 'command not found'. Can anyone help?

I'm seeing this as well ("command not found: gatsby" upon running gatsby --version after npm 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

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 +-- [email protected]
`-- [email protected]
what to do now ?
Screenshot (215)

I'm having the same issue! It's showing all good but when I run the command it says 'command not found'. Can anyone help?

ok. lets try this. Go to your system environment variables and add environment variable as my-admin-account with value C:\Users\AppData\Roamingnpm.
this might work.
check this, it might help.
https://github.com/gatsbyjs/gatsby/issues/2509#issuecomment-384779247

I'm seeing this as well ("command not found: gatsby" upon running gatsby --version after npm 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

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 +-- [email protected]
`-- [email protected]
what to do now ?
Screenshot (215)

I'm having the same issue! It's showing all good but when I run the command it says 'command not found'. Can anyone help?

ok. lets try this. Go to your system environment variables and add environment variable as my-admin-account with value C:\Users\AppData\Roamingnpm.
this might work.
check this, it might help.
#2509 (comment)

I've already set that value. npm -g ls --depth=0 returns

C:\usr\local

Any other things to debug?

Finally fixed this. Gatsby installed at some other folder so adding the path to the environment variable solved the issue. Thanks! @rutikwankhade

@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 use

npm config delete prefix

since nvm is not compatible with the npm config "prefix" option.

Otherwise, if you don't use nvm, you can just run

npm config set prefix /usr/local

Step 2 - Install Gatsby

Install gatsby globally with npm

npm i -g gatsby-cli

Step 3 - Verify Installation

Verify gatsby is installed correctly by listing all the packages you have installed globally at the first level (so not dependencies)

npm -g ls --depth=0

which should output something like this

/usr/local/lib
└── [email protected]

Step 4 - Huzzah

Success! Now you can use gatsby in all its loveliness.

gatsby new lovely-gatsby-site

Thanks!
Work for me!

I got this error

`/usr/local/lib/node_modules/gatsby-cli/node_modules/yoga-layout-prebuilt/yoga-layout/build/Release/nbind.js:53
throw ex;
^

Error: Package exports for '/usr/local/lib/node_modules/gatsby-cli/node_modules/clipboardy' do not define a '.' subpath
at resolveExports (internal/modules/cjs/loader.js:419:17)
at Function.Module._findPath (internal/modules/cjs/loader.js:492:20)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:787:27)
at Function.Module._load (internal/modules/cjs/loader.js:693:27)
at Module.require (internal/modules/cjs/loader.js:864:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object. (/usr/local/lib/node_modules/gatsby-cli/lib/create-cli.js:24:20)
at Module._compile (internal/modules/cjs/loader.js:971:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1011:10)
at Module.load (internal/modules/cjs/loader.js:822:32) {
code: 'MODULE_NOT_FOUND'
}`

please help me.

@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 use

npm config delete prefix

since nvm is not compatible with the npm config "prefix" option.

Otherwise, if you don't use nvm, you can just run

npm config set prefix /usr/local

Step 2 - Install Gatsby

Install gatsby globally with npm

npm i -g gatsby-cli

Step 3 - Verify Installation

Verify gatsby is installed correctly by listing all the packages you have installed globally at the first level (so not dependencies)

npm -g ls --depth=0

which should output something like this

/usr/local/lib
└── [email protected]

Step 4 - Huzzah

Success! Now you can use gatsby in all its loveliness.

gatsby new lovely-gatsby-site

thansk worked for me

@ bfeldman89 Aquí están los pasos que tomé que resolvieron el problema para mí también en base a los pasos de @pereiraryan .

Paso 1 - Establecer configuración

Si está usando nvm, quiere usar

npm config eliminar prefijo

ya nvmque no es compatible con la opción "prefijo" de configuración npm.

De lo contrario, si no usa nvm, simplemente puede ejecutar

npm config set prefix / usr / local

Paso 2 - Instala Gatsby

Instalar gatsbyglobalmente connpm

npm i -g gatsby-cli

Paso 3: verificar la instalación

Verifique que gatsby esté instalado correctamente enumerando todos los paquetes que ha instalado globalmente en el primer nivel (por lo tanto, no dependencias)

npm -g ls --depth = 0

que debería generar algo como esto

/ usr / local / lib 
└── [email protected]

Paso 4 - Huzzah

¡Éxito! Ahora puedes usarlo gatsbyen toda su belleza.

gatsby new lovely-gatsby-site

Eres un subnormal qu eno tiene ni puta idea. La qu ehe liado por tú culpa.Inútil!

npm WARN deprecated @hapi/[email protected]: joi is leaving the @hapi organization and moving back to 'joi' (https://github.com/sideway/joi/issues/2411)
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 @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 [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated [email protected]: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated [email protected]: GraphQL Import has been deprecated and merged into GraphQL Tools, so it will no longer get updates. Use GraphQL Tools instead to stay up-to-date! Check out https://www.graphql-tools.com/docs/migration-from-import for migration and https://the-guild.dev/blog/graphql-tools-v6 for new changes.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/gatsby/node_modules/babel-plugin-add-module-exports/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"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/gatsby/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"})

npm ERR! Unexpected end of JSON input while parsing near '...cies":{"react":"^16.1'

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-08-14T12_54_33_674Z-debug.log

what should i do

Does npm -g ls --depth=0 list gatsby-cli as being installed?

When i use npm install -g gatsby-cli, it works on one terminal fine but after i close that terminal and work on other terminal it dosen't work. And dosent showing in npm -g ls --depth=0

Does npm -g ls --depth=0 list gatsby-cli as being installed?

It said "empty" in my terminal, Do you have a solution for it?

GATSBY FUCKING SUKS! you install the cli and then it fducking doesnt find gatsby command!!???

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

To avoid having to use sudo when installing node dependencies it's recommended to use tools like https://github.com/nvm-sh/nvm to install a specific node version locally.

@SSylvain1989 Nothing in the blockquote seem like it's actually erroring (lots of warning are printed though). What's the error you are running into? (Please share full output even if it's hundreds of lines)

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

    /mnt/c/Users/Sylvain/test-gatsby  on   master                                              at 19:03:50  
❯ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 13527  100 13527    0     0  54765      0 --:--:-- --:--:-- --:--:-- 54765
=> Downloading nvm from git to '/home/sylvain/.nvm'
=> Cloning into '/home/sylvain/.nvm'...
remote: Enumerating objects: 333, done.
remote: Counting objects: 100% (333/333), done.
remote: Compressing objects: 100% (283/283), done.
remote: Total 333 (delta 38), reused 150 (delta 25), pack-reused 0
Receiving objects: 100% (333/333), 177.11 KiB | 740.00 KiB/s, done.
Resolving deltas: 100% (38/38), done.
=> Compressing and cleaning up git repository

=> Appending nvm source string to /home/sylvain/.bashrc
=> Appending bash_completion source string to /home/sylvain/.bashrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

    /mnt/c/Users/Sylvain/test-gatsby  on   master                                  took 6s   at 19:05:28  
❯ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
=> nvm is already installed in /home/sylvain/.nvm, trying to update using git
=> => Compressing and cleaning up git repository

=> nvm source string already in /home/sylvain/.bashrc
=> bash_completion source string already in /home/sylvain/.bashrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
Was this page helpful?
0 / 5 - 0 ratings

Related issues

benstr picture benstr  ·  3Comments

dustinhorton picture dustinhorton  ·  3Comments

dustinhorton picture dustinhorton  ·  3Comments

brandonmp picture brandonmp  ·  3Comments

ferMartz picture ferMartz  ·  3Comments