gatsby: gatsby-cli broken after upgrade: Error: Cannot find module './create-cli'

Description

Gatsby CLI not working after upgrade.

Steps to reproduce

npm i -g gatsby-cli

Expected result

gatsby-cli should work normally after upgrade

Actual result

screen shot 2018-12-28 at 6 29 44 pm
Error: Cannot find module './create-cli'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/gatsby-cli/lib/index.js:70:19)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)

Environment

Run gatsby info --clipboard in your project directory and paste the output here. Not working? You may need to update your global gatsby-cli - npm install -g gatsby-cli

gatsby info --clipboard does not work now. Unable to run gatsby-cli.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 27 (8 by maintainers)

Most upvoted comments

Quick followup. The only thing that fixed this issue for me was reinstalling node.js entirely. After that I reinstalled gatsby-cli and everything started working again. @sidharthachatterjee I did this before seeing your message. Not sure if that output would reflect the state it was in while the error was happening as it’s fixed now.

@irenedemas if you don’t mind i would like for you to do one thing. As you’re using npm

npm cache clean

What this will do is purge the global npm cache. Install gatsby cli again using the following command sudo npm install -g gatsby-cli assuming you are running ubuntu, if not adjust for your setup.

My reasoning behind this, because on a old machine i had laying around, this issue popped up and no matter how many ways i went about it, the result was the same you’re experiencing, which is according to a bit of investigation, npm was going for the cached version and not for the remote version and if the cached version had some issues, then it would propagate it.

Feel free to provide feedback

@DSchau I am really sorry for the delay in answering. Now when I use a new starter (e.g. ueno’s) everything works but when I try to gatsby develop my previous project I get this error:

success delete html files from previous builds — 0.016 s
success open and validate gatsby-config.js — 0.007 s
error UNHANDLED REJECTION


  Error: Unable to find plugin "gatsby-remark-images"

  - load-plugins.js:96 resolvePlugin
    [portfolioirene]/[gatsby]/dist/bootstrap/load-plugins.js:96:11

  - load-plugins.js:147 processPlugin
    [portfolioirene]/[gatsby]/dist/bootstrap/load-plugins.js:147:27

  - load-plugins.js:130
    [portfolioirene]/[gatsby]/dist/bootstrap/load-plugins.js:130:35

  - Array.forEach

  - load-plugins.js:129 processPlugin
    [portfolioirene]/[gatsby]/dist/bootstrap/load-plugins.js:129:40

  - load-plugins.js:168
    [portfolioirene]/[gatsby]/dist/bootstrap/load-plugins.js:168:28

  - Array.forEach

  - load-plugins.js:167 _callee$
    [portfolioirene]/[gatsby]/dist/bootstrap/load-plugins.js:167:28

  - new Promise

Any ideas on how to fix it or where I should look?

Thank you and sorry again.

I have the exact same problem:

running yarn dev results in:

alex@SURFACE-ALEX C:\Users\alex\vermehrung
$ yarn dev
yarn run v1.13.0
$ cross-env HASURA_GRAPHQL_URL=https://api.vermehrung.apflora.ch/v1alpha1/graphql gatsby develop
internal/modules/cjs/loader.js:611
    throw err;
    ^

Error: Cannot find module 'gatsby-cli'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:609:15)
    at Function.Module._load (internal/modules/cjs/loader.js:535:25)
    at Module.require (internal/modules/cjs/loader.js:663:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (C:\Users\alex\vermehrung\node_modules\gatsby\dist\bin\gatsby.js:4:1)
    at Module._compile (internal/modules/cjs/loader.js:734:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:745:10)
    at Module.load (internal/modules/cjs/loader.js:626:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:566:12)
    at Function.Module._load (internal/modules/cjs/loader.js:558:3)
error Command failed with exit code 1.

Running npx gatsby info --clipboard results in: Cannot find module 'gatsby-cli.

I have repeatedly:

  • removed yarn.lock
  • removed then reinstalled node_modules
  • uninstalled gatsby-cli
  • cleaned npm cache (global installs are done using npm, local using yarn)

I am using:

  • Windows 10 up to date
  • node v11.9.0

I am badly struck as none of my gatsby projects run anymore 😦