gatsby: Gatsby-cli not working

Getting the following error since updating to gatsby-cli@2.8.6

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

Error: Cannot find module 'gatsby-core-utils'
Require stack:
- /usr/local/lib/node_modules/gatsby-cli/lib/reporter/errors.js
- /usr/local/lib/node_modules/gatsby-cli/lib/reporter/index.js
- /usr/local/lib/node_modules/gatsby-cli/lib/create-cli.js
- /usr/local/lib/node_modules/gatsby-cli/lib/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
    at Function.Module._load (internal/modules/cjs/loader.js:687:27)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/gatsby-cli/lib/reporter/errors.js:13:18)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:849:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/local/lib/node_modules/gatsby-cli/lib/reporter/errors.js',
    '/usr/local/lib/node_modules/gatsby-cli/lib/reporter/index.js',
    '/usr/local/lib/node_modules/gatsby-cli/lib/create-cli.js',
    '/usr/local/lib/node_modules/gatsby-cli/lib/index.js'
  ]
}

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 7
  • Comments: 33 (3 by maintainers)

Most upvoted comments

I’m still having this issue on Windows using:

node version 14.17.6 (the latest LTS version) gatsby-cli (installed globally) version 3.13.0 (the latest version)

To Reproduce

  1. open cmd on your Desktop directory
  2. Execute the command gatsby new gatsby-bug to start the new Gatsby project.
  3. Execute the commands cd gatsby-bug and gatsby develop to try to start the development server.

This gives me the following error:

C:\Users\Chris\Desktop\gatsby-bug>gatsby develop
C:\Users\Chris\Desktop\gatsby-bug\node_modules\yoga-layout-prebuilt\yoga-layout\build\Release\nbind.js:53
        throw ex;
        ^

Error: Cannot find module 'gatsby-core-utils'
Require stack:
- C:\Users\Chris\Desktop\gatsby-bug\node_modules\babel-plugin-remove-graphql-queries\index.js
- C:\Users\Chris\Desktop\gatsby-bug\node_modules\gatsby\dist\query\file-parser.js
- C:\Users\Chris\Desktop\gatsby-bug\node_modules\gatsby\dist\query\query-compiler.js
- C:\Users\Chris\Desktop\gatsby-bug\node_modules\gatsby\dist\query\query-watcher.js
- C:\Users\Chris\Desktop\gatsby-bug\node_modules\gatsby\dist\services\extract-queries.js
- C:\Users\Chris\Desktop\gatsby-bug\node_modules\gatsby\dist\services\index.js
- C:\Users\Chris\Desktop\gatsby-bug\node_modules\gatsby\dist\state-machines\develop\services.js
- C:\Users\Chris\Desktop\gatsby-bug\node_modules\gatsby\dist\state-machines\develop\index.js
- C:\Users\Chris\Desktop\gatsby-bug\node_modules\gatsby\dist\commands\develop-process.js
- C:\Users\Chris\Desktop\gatsby-bug\.cache\tmp-20104-WGMTq0uj61Jv
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
    at Function.Module._load (internal/modules/cjs/loader.js:745:27)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at require (C:\Users\Chris\Desktop\gatsby-bug\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
    at Object.<anonymous> (C:\Users\Chris\Desktop\gatsby-bug\node_modules\babel-plugin-remove-graphql-queries\index.js:19:24)
    at Module._compile (C:\Users\Chris\Desktop\gatsby-bug\node_modules\v8-compile-cache\v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at require (C:\Users\Chris\Desktop\gatsby-bug\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
    at Object.<anonymous> (C:\Users\Chris\Desktop\gatsby-bug\node_modules\gatsby\src\query\file-parser.js:15:5)
    at Module._compile (C:\Users\Chris\Desktop\gatsby-bug\node_modules\v8-compile-cache\v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\Chris\\Desktop\\gatsby-bug\\node_modules\\babel-plugin-remove-graphql-queries\\index.js',
    'C:\\Users\\Chris\\Desktop\\gatsby-bug\\node_modules\\gatsby\\dist\\query\\file-parser.js',
    'C:\\Users\\Chris\\Desktop\\gatsby-bug\\node_modules\\gatsby\\dist\\query\\query-compiler.js',
    'C:\\Users\\Chris\\Desktop\\gatsby-bug\\node_modules\\gatsby\\dist\\query\\query-watcher.js',
    'C:\\Users\\Chris\\Desktop\\gatsby-bug\\node_modules\\gatsby\\dist\\services\\extract-queries.js',
    'C:\\Users\\Chris\\Desktop\\gatsby-bug\\node_modules\\gatsby\\dist\\services\\index.js',
    'C:\\Users\\Chris\\Desktop\\gatsby-bug\\node_modules\\gatsby\\dist\\state-machines\\develop\\services.js',
    'C:\\Users\\Chris\\Desktop\\gatsby-bug\\node_modules\\gatsby\\dist\\state-machines\\develop\\index.js',
    'C:\\Users\\Chris\\Desktop\\gatsby-bug\\node_modules\\gatsby\\dist\\commands\\develop-process.js',
    'C:\\Users\\Chris\\Desktop\\gatsby-bug\\.cache\\tmp-20104-WGMTq0uj61Jv'
  ]
}

I also tried creating the project folder first, then running gatsby new . inside of it, which gave similar results.

What Did Work

  1. Open cmd and execute the command gatsby new (without any arguments) in the parent directory of where you want your new Gatsby project (for example, execute gatsby new on your Desktop directory if you want it to live in Desktop\my-gatsby-site\).
  2. Follow the steps in the guided setup. Use the default values for everything.
  3. Execute cd my-gatsby-site and then gatsby develop. The server should run without any issues.

Final Thoughts

I’ve found this work-around, but I think this issue should be re-opened since I’m not the only one having this problem.

It’s very interesting that @lorensr fixed this problem by updating to node@14, @kubarbaz fixed it by changing from Latest Version to LTS, and I’m having the issue with LTS. Maybe the act of simply re-installing Node is what did it? I don’t really feel like re-installing Node to find out.

I also didn’t try installing gatsby globally with npm install -g gatsby. It just feels kind of hacky. What if your project’s Gatsby version is different than the globally installed version? Couldn’t that cause problems?

I was having the same problem today, just installed node 12 on ubuntu (mate) 19.10 and run to install gatsby-cli. I think that usually I only install gatsby-cli, but this time I had to install also gatsby ( npm install -g gatsby ) and everything began to work.

Yep, facing the same issue.

Error: Cannot find module 'gatsby-core-utils'

@RaulCote Does running npm i -g gatsby solve the issue?

Node: 10.16.3

To me it did the trick.

Still happens for me as well. Running npm i gatsby-core-utils fixed it.

I had the Cannot find module 'gatsby-core-utils' error coming from ./node_modules/yoga-layout-prebuilt with gatsby@2.32.8 and node@12. Switching to node@14 removed the error.

Thank you @sidharthachatterjee for getting this fixed so quickly, closing.

Apologies for this, just published a fix in gatsby-cli@2.8.7

Please test and close this 🙂

Yesterday I have installed nodejs 14.17.6 LTS then npm install -g gatsby-cli after that I created a new project gatsby new my-app all was installed with no errors, then I went into the folder cd my-app and tried to start the local server gatsby develop, and voila: `…/Desktop/my-app/node_modules/yoga-layout-prebuilt/yoga-layout/build/Release/nbind.js:53 throw ex; ^

Error: Cannot find module ‘gatsby-core-utils’`

I tried all the above options nothing helped.

OS: macOS BigSur 11.5.2 Gatsby CLI version: 3.13.0 Gatsby version: 3.13.0

Follow up: after another full clean install of the repo and cli it is working. Not sure what the issue was.

On Tue, Jun 30, 2020 at 5:38 PM moses gunesch notifications@github.com wrote:

Actually when I look at it, this is a slightly different error, but the cli isn’t loading either way.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/gatsbyjs/gatsby/issues/19088#issuecomment-652119644, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAF6GOPJN3EZGCZNTK4SJ3RZKARXANCNFSM4JF6E4SA .

Thanks 🐱‍💻

Yep, facing the same issue.

Error: Cannot find module 'gatsby-core-utils'

@RaulCote Does running npm i -g gatsby solve the issue?

Node: 10.16.3