Search code examples
npmgitlabdependenciesrepositorygit-clone

Git clone with npm failing


I have a project as dependency for other projects in GitLab. I created a project access token to use npm to pull the project from the GitLab server like a private package. The following line I added in the packages.json of the dependent project (project name, token and path are replaced with random stuff).

"private-project": "git+https://npm:[email protected]:9999/private-team/private-project#v0.2.4-1",

This did work without problems, until we moved GitLab to another server. Now I get this error message, if I try to get it with npm.

verbose stack TypeError: Cannot read properties of undefined (reading 'sha')

I really don't know what is going wrong. I created multiply new tokens and I always get the same error. Has someone at least an idea why this is happening?

My colleague somehow did this all get working again in the pipeline of the GitLab server, but he needed to downgrade the node version to 14. I need it locally too, and downgrading Node sounds bad for me.

project-acces-token

bug-log


Solution

  • The problem was the HEAD was missing in the repository after the server move. Changing in GitLab the default branch of the repository under Settings->Repository to something else and then back to master fixed it. Using git fetch --prune after that on the local copy is also needed.