как исправить ошибку при установке npm: "Произошла неизвестная ошибка git" в одной папке, но работает в другой

Мой сервер работает на Centos 8 и я установил nodejs последней версии (v14.17.5) и NPM (v7.21.0), у обоих нет папки .git.

У меня очень странная проблема, если я захожу в папку example1.com и запускаю npm install, я получаю следующую ошибку,

[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://git@github.com/Defipoolhub/node-time.git
npm ERR! git@github.com: 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

Однако если я захожу в другую папку, на тот же сервер и с тем же package.json, я не получаю никаких проблем, как такое может быть,

[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.

Есть идеи, как отладить эту проблему, я сделал отключение SELinux и это не решило проблему.

0
задан 23 August 2021 в 10:13
1 ответ

У меня была аналогичная проблема, хотя после ошибки команды git он сказал, что не может записать или создать каталог tmp. Я использую Ubuntu, и это сработало для меня (не уверен, что это чистое решение, мне просто нужно, чтобы оно поработало несколько дней)

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

Надеюсь, это поможет!!

0
ответ дан 24 August 2021 в 18:12

Теги

Похожие вопросы