Score:0

how to fix the npm install fails with 'An unknown git error occurred' in one folder but works in a another folder

cn flag

My Server runs on Centos 8 and I installed nodejs latest (v14.17.5) and NPM (v7.21.0), both dont have a .git folder in there.

I have a very very strange issue, If I goto folder example1.com, and run npm install I get the below error,

[root@www centos]# cd /var/www/example1.com/httpdocs/
[root@www chat]#  npm install
npm WARN old lockfile
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile
npm ERR! code 128
npm ERR! An unknown git error occurred
npm ERR! command git --no-replace-objects ls-remote ssh://[email protected]/Defipoolhub/node-time.git
npm ERR! [email protected]: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-08-23T10_03_50_797Z-debug.log

However if goto a different folder, same server, and same package.json, i get no issues at all, how could it be like that,

[root@www centos]# cd /var/www/example2.com/httpdocs/
[root@www chat]#  npm install

up to date, audited 224 packages in 3s

4 packages are looking for funding
  run `npm fund` for details

4 vulnerabilities (2 low, 2 high)

To address all issues possible (including breaking changes), run:
  npm audit fix --force

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.

Any idea on how to debug this issue, i did the SELinux disable and that didnt solve the problem.

Score:0
in flag

I was having a similar issue, although after the git command error it said it couldn't write or create a tmp directory. I use Ubuntu, and this worked for me (not sure if it's a clean solution, I just need it to work for a few days tbh)

sudo npm cache clean -f
sudo npm install -g n
sudo n stable
sudo npm install --unsafe-perm=true --allow-root

Hope this helps!!

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.