Search code examples
node.jsnpmgatsby

Gatsby Terminal Issue: Cannot find module 'rimraf'


I'm creating a client project using Gatsby. On my PC when I try to run the command "Gatsby develop" it throws errors that I couldn't solve.

I have attached the ERROR thrown below.

I tried installing the missing modules and reinstalling the node and other extensions those didn't help.

But It's working fine on the other developer's PCs, I have this issue only on my PC. [Note: Gatsby starter kit is working fine with gatsby develop, only my current project doesn't.]


gatsby develop

Start development server. Watches files, rebuilds, and hot reloads if something changes

Options:
  --verbose                   Turn on verbose output                                                 [boolean] [default: false]
  --no-color, --no-colors     Turn off the color in output                                           [boolean] [default: false]
  --json                      Turn on the JSON logger                                                [boolean] [default: false]
  -H, --host                  Set host. Defaults to localhost                                   [string] [default: "localhost"]
  -p, --port                  Set port. Defaults to 8000                                             [string] [default: "8000"]
  -o, --open                  Open the site in your (default) browser for you.                                        [boolean]
  -S, --https                 Use HTTPS. See https://www.gatsbyjs.com/docs/local-https/ as a guide                    [boolean]
  -c, --cert-file             Custom HTTPS cert file (also required: --https, --key-file). See
                              https://www.gatsbyjs.com/docs/local-https/                                 [string] [default: ""]
  -k, --key-file              Custom HTTPS key file (also required: --https, --cert-file). See
                              https://www.gatsbyjs.com/docs/local-https/                                 [string] [default: ""]
  --ca-file                   Custom HTTPS CA certificate file (also required: --https, --cert-file, --key-file).  See
                              https://www.gatsbyjs.com/docs/local-https/                                 [string] [default: ""]
  --graphql-tracing           Trace every graphql resolver, may have performance implications        [boolean] [default: false]
  --open-tracing-config-file  Tracer configuration file (OpenTracing compatible). See https://gatsby.dev/tracing       [string]
  --inspect                   Opens a port for debugging. See https://www.gatsbyjs.com/docs/debugging-the-build-process/       
                                                                                                                       [number]
  --inspect-brk               Opens a port for debugging. Will block until debugger is attached. See
                              https://www.gatsbyjs.com/docs/debugging-the-build-process/                               [number]
  -h, --help                  Show help                                                                               [boolean]
  -v, --version               Show the version of the Gatsby CLI and the Gatsby package in the current project        [boolean]


 ERROR 

There was a problem loading the local develop command. Gatsby may not be installed. Perhaps you need to run "npm install"?     
Cannot find module 'rimraf'
Require stack:
- C:\CREST\Sri Nidhi\github\Dot-Matters-Gatsby\node_modules\tmp\lib\tmp.js
- C:\CREST\Sri Nidhi\github\Dot-Matters-Gatsby\node_modules\gatsby\dist\commands\develop.js
- C:\Users\Sriram Ayyagari\AppData\Roaming\npm\node_modules\gatsby-cli\lib\create-cli.js
- C:\Users\Sriram Ayyagari\AppData\Roaming\npm\node_modules\gatsby-cli\lib\index.js
- C:\Users\Sriram Ayyagari\AppData\Roaming\npm\node_modules\gatsby-cli\cli.js



  Error: Cannot find module 'rimraf'
  Require stack:
  - C:\CREST\Sri Nidhi\github\Dot-Matters-Gatsby\node_modules\tmp\lib\tmp.js
  - C:\CREST\Sri Nidhi\github\Dot-Matters-Gatsby\node_modules\gatsby\dist\commands\develop.js
  - C:\Users\Sriram Ayyagari\AppData\Roaming\npm\node_modules\gatsby-cli\lib\create-cli.js
  - C:\Users\Sriram Ayyagari\AppData\Roaming\npm\node_modules\gatsby-cli\lib\index.js
  - C:\Users\Sriram Ayyagari\AppData\Roaming\npm\node_modules\gatsby-cli\cli.js

  - loader:946 Function.Module._resolveFilename
    node:internal/modules/cjs/loader:946:15

  - loader:787 Function.Module._load
    node:internal/modules/cjs/loader:787:27

  - loader:1012 Module.require
    node:internal/modules/cjs/loader:1012:19

  - helpers:102 require
    node:internal/modules/cjs/helpers:102:18

  - tmp.js:17 Object.<anonymous>
    [Dot-Matters-Gatsby]/[tmp]/lib/tmp.js:17:16

  - loader:1112 Module._compile
    node:internal/modules/cjs/loader:1112:14

  - loader:1166 Object.Module._extensions..js
    node:internal/modules/cjs/loader:1166:10

  - loader:988 Module.load
    node:internal/modules/cjs/loader:988:32

  - loader:834 Function.Module._load
    node:internal/modules/cjs/loader:834:12

  - loader:1012 Module.require
    node:internal/modules/cjs/loader:1012:19

Solution

  • But It's working fine on the other developer's PCs, I have this issue only on my PC.

    I'd suggest checking both Node versions and using a .nvmrc file. This file is used as a base Node version when dealing with NVM.

    If you've tried running npm install and playing around with dependencies as you said the issue must be in the way they're installed. Ensure that you are running the same Node version and reinstall all the dependencies again.