question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error thrown when using the Gatsby CLI after install - "Error: Cannot find module 'detect-port'"

See original GitHub issue

Description

When I installed the gatsby CLI, I was unable to run it; it throws this exception in the command line:

image

This is only resolveable by globally installing detect-port, at which point everything is fine. Perhaps a missing dependency that wasn’t included?

Steps to reproduce

  1. Install gatsby-cli globally.
  2. Try to create a new site with the Gatsby CLI per the tutorial (or run gatsby -v - any command will cause the failure it seems)
  3. The above error is spat out

Expected result

What should happen?

It should not throw

Actual result

It throws an exception saying that detect-port could not be found.

Environment

System: OS: macOS 10.15.4 CPU: (16) x64 Intel® Core™ i9-9880H CPU @ 2.30GHz Shell: 5.7.1 - /bin/zsh Binaries: Node: 12.13.0 - ~/.nvm/versions/node/v12.13.0/bin/node Yarn: 1.22.4 - /usr/local/bin/yarn npm: 6.14.4 - ~/.nvm/versions/node/v12.13.0/bin/npm Languages: Python: 2.7.17 - /usr/local/bin/python Browsers: Chrome: 81.0.4044.138 Edge: 81.0.416.72 Firefox: 74.0.1 Safari: 13.1 npmGlobalPackages: gatsby-cli: 2.12.31

NB I had to do the above manual install of detect-port to get this to work

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:11
  • Comments:16 (2 by maintainers)

github_iconTop GitHub Comments

15reactions
lukenetti3commented, May 22, 2020

This exact same thing happened to me as well.

8reactions
valentinraducommented, May 22, 2020

Same here. One quick fix is to install everything locally:

yarn add gatsby-cli
yarn add detect-port
npx gatsby help

or install detect-port globally:

yarn global add gatsby-cli
yarn global add detect-port
gatsby help
Read more comments on GitHub >

github_iconTop Results From Across the Web

Fresh install of gatsby fails with cannot find module 'detect- ...
Installing yarn and running yarn build or yarn develop is a workaround for the moment. Share.
Read more >
Gatsby, fix the "cannot find module gatsby-cli/lib/reporter" ...
I created a site using Gatsby and I ran gatsby develop to start a local server. But a weird error showed up, coloring...
Read more >
Gatsby Changelog | 5.3.0
In normal circumstances the errors thrown by GraphQL or Gatsby itself will give you enough details to solve your error. Improved error during...
Read more >
Gatsby
This error occurs when plugins are being used that have not been installed. To remedy this, do an npm install -g . This...
Read more >
Top 5 detect-port Code Examples
Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately. Enable here. github gatsbyjs /...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found