next-learn: Could not locate the repository

I keep running into a “Could not locate the repository” error when following the instructions at https://nextjs.org/learn/basics/create-nextjs-app/setup

npx: installed 1 in 2.349s
Could not locate the repository for "https://github.com/vercel/next-learn/tree/master/basics/learn-starter". Please check that the repository exists and try again.

Instructions say to check https://github.com/vercel/next-learn/blob/master/basics/errors/install.md but there’s not much detail there and the commands are a bit different. I followed the text based instructions there (not the specific command) and removed everything past the project name which was then “Successful” but when starting the app it quickly failed for other reasons:

Installing dependencies:
- react
- react-dom
- next

+ react@17.0.2
+ react-dom@17.0.2
+ next@12.0.7
added 243 packages from 223 contributors and audited 255 packages in 44.584s
found 0 vulnerabilities


Installing devDependencies:
- eslint
- eslint-config-next


> core-js-pure@3.20.2 postinstall C:\code\nextjs-blog\node_modules\core-js-pure
> node -e "try{require('./postinstall')}catch(e){}"

+ eslint@8.6.0
+ eslint-config-next@12.0.7
added 170 packages from 100 contributors and audited 425 packages in 34.247s
found 0 vulnerabilities


Initialized a git repository.

Success! Created nextjs-blog at C:\code\nextjs-blog
 started server on 0.0.0.0:3000, url: http://localhost:3000
(node:19500) UnhandledPromiseRejectionWarning: ReferenceError: TextEncoder is not defined
    at C:\code\nextjs-blog\node_modules\next\dist\compiled\react-server-dom-webpack\cjs\react-server-dom-webpack-writer.browser.development.server.js:67:19
    at Object.<anonymous> (C:\code\nextjs-blog\node_modules\next\dist\compiled\react-server-dom-webpack\cjs\react-server-dom-webpack-writer.browser.development.server.js:900:5)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (C:\code\nextjs-blog\node_modules\next\dist\compiled\react-server-dom-webpack\writer.browser.server.js:6:20)
(node:19500) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:19500) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
error - Failed to load next.config.js, see more info here https://nextjs.org/docs/messages/next-config-error
Error: Not supported
    at Object.loadConfig [as default] (C:\code\nextjs-blog\node_modules\next\dist\server\config.js:399:74)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nextjs-blog@ dev: `next dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nextjs-blog@ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 5
  • Comments: 42

Most upvoted comments

The master branch no longer exists, so try the main branch instead.

npx create-next-app nextjs-blog --use-npm --example "https://github.com/vercel/next-learn/tree/main/basics/learn-starter"

I succeeded by turning off the VPN. Switching the network environment may be one of the solutions.

Updated node to latest with nvm install node and it worked.

I’ve met same issues. Here’s my solution:

  1. Check latest document for the template url. By now the create app command is:
npx create-next-app nextjs-blog --use-npm --example "https://github.com/vercel/next-learn/tree/master/basics/learn-starter"
  1. Install latest node.js version. When I was using node v10.12.x, I met same problem on starting up the project which showed me TextEncoder is not defined Error. Then I installed node.js v16.14.0 and npm run dev, it worked well.

Updated node to 18.19.0 and it worked.

In case others find this thread in the future…ran into the reported issue as well. Issue persisted while running node v16.15.0 but was finally able to create the next app using the example template with node v18.19.0.

So it really irritated me that the accepted solution to this was “If you’re on some sort of VPN/Proxy, try not being like that” - not an option for me and probably a lot of other people that work at actual companies of scale lol.

I’m well aware that this is related to my network configuration on my work VPN, but I also know with certainty that I am able to interact with all of the visible urls this npx command appeared to be making requests to.

At the very least, I know the error message that the create-next-app utility was printing out was wrong since it stated: “Could not locate the repository for “https://github.com/vercel/next-learn/tree/main/dashboard/starter-example”. Please check that the repository exists and try again.” but I can reach that url just fine on my network.

So I dug into the actual create-next-app code that runs when you npx create-next-app which you can find here. This brought me to the isUrlOK() call, as this seemed to be where the falsy value came which leads to the error message that brought us all to this github issue…

Lo and behold, the url it’s fetching from to confirm a valid example project url was “https://api.github.com/repos/vercel/next-learn/contents/dashboard/starter-example/package.json?ref=main”… I can already tell you what is going to happen if I paste this into my browser and try it (and so could probably anyone else that works at big enterprises)…

403 - RATE LIMITED 🤦‍♂️

{
  "message": "API rate limit exceeded for <my.ip>. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)",
  "documentation_url": "https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting"
}

After figuring out how to build the monstrosity of javascript build tools and abstractions that is the next.js monorepo, and then figuring out how to get npx to use my create-react-app package instead of whatever’s hosted on the public (or in my case private) npm registry, I was able to at least log out what the hell create-react-app was trying to do to confirm this was the issue. This also let me add my bearer token as a header on the fetch call that’s validating this repo’s existence and once built, my local version of the create-next-app tool works as expected on network!

The create-next-app utility needs a few things:

  1. The error messages are incorrect and should be at minimum modified to include the response text when failing.
  2. Probably needs the ability to pass args to create-next-app that do things like set headers for requests to github api.

Tl;dr - Its problems with the create-next-app utility, and if you can’t change networks to make this work, you’ll need to not use create-next-app or customize that tool as I roughly detailed above.

the app init command npx create-next-app nextjs-blog --use-npm --example "https://github.com/vercel/next-learn/tree/master/basics/learn-starter" still results in the same error as before Could not locate the repository for “https://github.com/vercel/next-learn/tree/master/basics/learn-starter”. Please check that the repository exists and try again. Starting a project without example template using npx create-next-app next-blog works fine but of course that doesn’t make use of the template.

@BazzSivan1 Try updating your node first nvm install node

and then run npx create-next-app@latest nextjs-dashboard --use-npm --example "https://github.com/vercel/next-learn/tree/main/dashboard/starter-example"

The master branch no longer exists, so try the main branch instead. it worked.

Apparently this issue is back again. Which is not exactly a big deal since we can just use the executable and follow the prompts, but it’s not really a good thing when the official documentation points to commands that don’t work.

user@laptop ~/t/sound-esp-2024 (dev) [1]> npx create-next-app@latest nextjs-blog --use-npm --example "https://github.com/vercel/next-learn/tree/main/basics/learn-starter"
Need to install the following packages:
create-next-app@13.5.3
Ok to proceed? (y) y
Could not locate the repository for "https://github.com/vercel/next-learn/tree/main/basics/learn-starter". Please check that the repository exists and try again.

I keep running into a “Could not locate the repository” error when following the instructions at https://nextjs.org/learn/basics/create-nextjs-app/setup

npx: installed 1 in 2.349s
Could not locate the repository for "https://github.com/vercel/next-learn/tree/master/basics/learn-starter". Please check that the repository exists and try again.

Instructions say to check https://github.com/vercel/next-learn/blob/master/basics/errors/install.md but there’s not much detail there and the commands are a bit different. I followed the text based instructions there (not the specific command) and removed everything past the project name which was then “Successful” but when starting the app it quickly failed for other reasons:

Installing dependencies:
- react
- react-dom
- next

+ react@17.0.2
+ react-dom@17.0.2
+ next@12.0.7
added 243 packages from 223 contributors and audited 255 packages in 44.584s
found 0 vulnerabilities


Installing devDependencies:
- eslint
- eslint-config-next


> core-js-pure@3.20.2 postinstall C:\code\nextjs-blog\node_modules\core-js-pure
> node -e "try{require('./postinstall')}catch(e){}"

+ eslint@8.6.0
+ eslint-config-next@12.0.7
added 170 packages from 100 contributors and audited 425 packages in 34.247s
found 0 vulnerabilities


Initialized a git repository.

Success! Created nextjs-blog at C:\code\nextjs-blog
 started server on 0.0.0.0:3000, url: http://localhost:3000
(node:19500) UnhandledPromiseRejectionWarning: ReferenceError: TextEncoder is not defined
    at C:\code\nextjs-blog\node_modules\next\dist\compiled\react-server-dom-webpack\cjs\react-server-dom-webpack-writer.browser.development.server.js:67:19
    at Object.<anonymous> (C:\code\nextjs-blog\node_modules\next\dist\compiled\react-server-dom-webpack\cjs\react-server-dom-webpack-writer.browser.development.server.js:900:5)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (C:\code\nextjs-blog\node_modules\next\dist\compiled\react-server-dom-webpack\writer.browser.server.js:6:20)
(node:19500) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:19500) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
error - Failed to load next.config.js, see more info here https://nextjs.org/docs/messages/next-config-error
Error: Not supported
    at Object.loadConfig [as default] (C:\code\nextjs-blog\node_modules\next\dist\server\config.js:399:74)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nextjs-blog@ dev: `next dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nextjs-blog@ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

This was caused by some problem in proxy configuration as my institute uses a proxy server. I could use npm, git and apt by manually configuring proxies but this

npx create-next-app nextjs-blog --use-npm --example "https://github.com/vercel/next-learn/tree/master/basics/learn-starter" was failing.

npx create-next-app nextjs-blog works fine, most probably using the proxy for npm but the former fails. Temporary Workaround: I’m using a VPN with proxy which routes all traffic through the proxy server and although the speed is a setback, it gets the work done.