no required module provides package Go Origin: Application & API Last updated 4 Nov 2026

Go: no required module provides package github.com/foo/bar; to add it: go get github.com/foo/bar

The code imports a package whose module is not listed in go.mod.

Exact message you may see no required module provides packagego: go.mod file not found in current directory or any parent directoryno required module provides package github.com/foo/bar; to add it: go getcannot find module providing packagego: cannot find main module, but found .git/config
Seen on: Go

Meaning

Run go get github.com/foo/bar or go mod tidy. If the import path is wrong, fix it. Outside a module you'll see go: go.mod file not found in current directory or any parent directory — run go mod init first.

Common causes

  • Dependency never added
  • Typo in import path
  • Running outside the module directory
  • Package moved to a new module path (v2 suffix)
  • Private repository not fetched

⚡ Quick fix

  1. go get github.com/foo/bar@latest
  2. go mod init example.com/app if there is no go.mod
  3. Check major version suffix (/v2)

Detailed fix by platform

Go

  1. go list -m all shows the resolved module graph

How to diagnose

  1. Module — Listed in go.mod?
  2. Path — Correct (v2+)?
  3. Directory — Inside the module?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

cannot find package in any of GOROOT / GOPATH — Go: cannot find package "github.com/pkg/errors" in any of: /usr/local/go/src/github.com/pkg/errors (from $GOROOT) /go/src/github.com/pkg/errors (from $GOPATH) (Go)cannot find package i…go: updates to go.mod needed — Go: go: updates to go.mod needed; to update it: go mod tidy (Go)go: updates to go.mod…import cycle not allowed — Go: package app/models imports app/utils imports app/models: import cycle not allowed (Go)import cycle not allo…invalid version: unknown revision — Go: go: github.com/foo/bar@v1.2.3: invalid version: unknown revision v1.2.3 (Go)invalid version: unkn…listen tcp :8080: bind: address already in use — Go: listen tcp :8080: bind: address already in use (Go)listen tcp :8080: bin…missing go.sum entry — Go: missing go.sum entry for module providing package github.com/pkg/errors (imported by app); to add: go get app (Go)missing go.sum entryno Go files in directory — Go: package app/cmd: no Go files in /app/cmd / build constraints exclude all Go files (Go)no Go files in direct…terminal prompts disabled / 410 Gone (private module) — Go: fatal: could not read Username for 'https://github.com': terminal prompts disabled (Go)terminal prompts disa…no requir…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.