Deploy fails on sub git repository which is private


I have a domain on netlify which is linked to a public git repository. Regarding A nextJS project. Worked perfectly fine. Locally I started working on a new feature where I fetch data from a private github repository (repo is maintained by me, same account as the public one is).

Folder structure is like this:
Nextjs app
.git – linked to
pages/xxx/private-api-remote/.git – Here I did git clone privateurl.

Locally this works perfectly fine, I can just clone the private repo in my initial repo, but while deploying to netlify production I get some errors which I assume are because it’s private. How do I work around this? i’ve googled some and tried some solutions but can’t get it to deploy.

Besides the initial git pull private remoteurl i’ve also tried removing the remote/folder and clone with git add submodule privateurl wihich also failed.

This is the error i’m getting:

@hoxyz Related documentation is here:

I have added it as a submodule. Also generated netlify’s deploy key and added that ssh key to github. Still won’t deploy…
1:26:09 AM: Waiting for other deploys from your team to complete. Check the queue: Netlify App

1:26:15 AM: build-image version: 5ad27658ebdf9c1e4379d77be303c2a3e3daa7bf (focal)

1:26:15 AM: buildbot version: 5ad27658ebdf9c1e4379d77be303c2a3e3daa7bf

1:26:15 AM: Fetching cached dependencies

1:26:15 AM: Starting to download cache of 355.0MB

1:26:16 AM: Finished downloading cache in 1.392s

1:26:16 AM: Starting to extract cache

1:26:19 AM: Finished extracting cache in 2.674s

1:26:19 AM: Finished fetching cache in 4.119s

1:26:19 AM: Starting to prepare the repo for build

1:26:19 AM: Preparing Git Reference refs/heads/feature/chat-search

1:26:20 AM: Error checking out submodules:

1:26:20 AM: Failing build: Failed to prepare repo

1:26:20 AM: Failed during stage ‘preparing repo’: Error checking out submodules: : Submodule ‘private’ ( registered for path ‘private’
Cloning into ‘/opt/build/repo/private’…
fatal: could not read Username for ‘’: No such device or address
fatal: clone of ‘’ into submodule path ‘/opt/build/repo/private’ failed
Failed to clone ‘private’. Retry scheduled
Cloning into ‘/opt/build/repo/private’…
fatal: could not read Username for ‘’: No such device or address
fatal: clone of ‘’ into submodule path ‘/opt/build/repo/private’ failed
Failed to clone ‘private’ a second time, aborting
: exit status 1

1:26:20 AM: Finished processing build request in 5.28s

Hi @hoxyz :wave:t6: ,

Sorry for the delay I checked your most recent deploy log. It looks like it is still failing to compile because it can’t identify the module. You can try uninstalling and reinstalling the module. If that doesn’t work this is what I found:

You need to install web vitals. Open your terminal and run the following command:

npm i web-vitals --save-dev

Hi thanks for checking the logs. Web vitals doesn’t sound familiar so I will make sure to remove that.

I’ve managed to deploy with the private sub module. I had to add the key generated over Ssh or https, can’t remember which one it was but the netlify docs do not state that. So the docs should be updated. I can look tomorrow what exactly is missing and write a small update.

Besides that my git is having quite some problems due to the sub modules and branches not merging properly. So I should turn off auto deployment. Or maybe there’s a way to make nextJS build less strict.