Gatsby: (gatsby-cli): Cannot find module 'react'

Created on 16 Sep 2020  路  6Comments  路  Source: gatsbyjs/gatsby

Try to start tutorial with Gatsby.

Description

D:\formation>gatsby
C:\Users\jlouis.JLG.000\AppData\Roaming\npm\node_modules\gatsby\node_modules\yoga-layout-prebuilt\yoga-layout\build\Release\nbind.js:53
        throw ex;
        ^

Error: Cannot find module 'react'
Require stack:
- C:\Users\jlouis.JLG.000\AppData\Roaming\npm\node_modules\gatsby\node_modules\gatsby-recipes\dist\index.js
- C:\Users\jlouis.JLG.000\AppData\Roaming\npm\node_modules\gatsby\node_modules\gatsby-cli\lib\recipes.js
- C:\Users\jlouis.JLG.000\AppData\Roaming\npm\node_modules\gatsby\node_modules\gatsby-cli\lib\create-cli.js
- C:\Users\jlouis.JLG.000\AppData\Roaming\npm\node_modules\gatsby\node_modules\gatsby-cli\lib\index.js
- C:\Users\jlouis.JLG.000\AppData\Roaming\npm\node_modules\gatsby\dist\bin\gatsby.js
- C:\Users\jlouis.JLG.000\AppData\Roaming\npm\node_modules\gatsby\cli.js

Steps to reproduce

Remove nodeJS from my Windows 10 computer:

  • Add or Remove Programs, then remove node.
  • Clean the %APPDATA%/npm and %APPDATA%/npm-cache.

Install nodejs v14.11.0 with all defaulted options.

Then

npm i -g gatsby
gatsby

Expected result

According the doc, I see a help screen...

Actual result

...But in fact, I get an error stack trace as described above.

Environment

Run gatsby info --clipboard in your project directory and paste the output here.
Sorry I cannot, I get the error stacktrace.

confirmed cli bug

Most helpful comment

As a workaround until fix gets merged and published - please do npm install -g [email protected] to use 1 version before the problem

All 6 comments

Sorry about that - I just opened pull request that reverts the change that caused this ( https://github.com/gatsbyjs/gatsby/pull/26921 )

As a workaround until fix gets merged and published - please do npm install -g [email protected] to use 1 version before the problem

Thank you for the information. I was having similar issues with gatsby clean throwing errors

```/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 'react'
Require stack:

  • /usr/local/lib/node_modules/gatsby-cli/node_modules/gatsby-recipes/dist/index.js
  • /usr/local/lib/node_modules/gatsby-cli/lib/recipes.js
  • /usr/local/lib/node_modules/gatsby-cli/lib/create-cli.js
  • /usr/local/lib/node_modules/gatsby-cli/lib/index.js
  • /usr/local/lib/node_modules/gatsby-cli/cli.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:892:15)
    at Function.Module._load (internal/modules/cjs/loader.js:742:27)
    at Module.require (internal/modules/cjs/loader.js:964:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object. (/usr/local/lib/node_modules/gatsby-cli/node_modules/gatsby-recipes/dist/index.js:7:15)
    at Module._compile (internal/modules/cjs/loader.js:1075:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1096:10)
    at Module.load (internal/modules/cjs/loader.js:940:32)
    at Function.Module._load (internal/modules/cjs/loader.js:781:14)
    at Module.require (internal/modules/cjs/loader.js:964:19) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
    '/usr/local/lib/node_modules/gatsby-cli/node_modules/gatsby-recipes/dist/index.js',
    '/usr/local/lib/node_modules/gatsby-cli/lib/recipes.js',
    '/usr/local/lib/node_modules/gatsby-cli/lib/create-cli.js',
    '/usr/local/lib/node_modules/gatsby-cli/lib/index.js',
    '/usr/local/lib/node_modules/gatsby-cli/cli.js'
    ]
    }
    ```

I'm publishing right now - will post another comment when it actually gets published on npm

Published [email protected] which is pretty much the same as [email protected]

Thanks for the QuickFix.
Is it possible to add CIT to the pipeline to be sure that the release still working ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rossPatton picture rossPatton  路  3Comments

theduke picture theduke  路  3Comments

signalwerk picture signalwerk  路  3Comments

Oppenheimer1 picture Oppenheimer1  路  3Comments

brandonmp picture brandonmp  路  3Comments