Özel repo'dan NPM ekleme, varolan bir projedeyken izin reddedildiğinde başarısız olur

0

Soru

Bu süper garip sorunu çözmeye çalışıyordum. Özel bir depo kurmaya çalıştığım bir projem var npm komut.

Bu, mevcut bir projedeyken işe yaramaz, ancak yeni oluşturulmuş yeni oluşturulmuş bir proje olduğunda işe yarar npm init.

Mevcut proje şu şekildedir: /app ve yeni proje başladı. /opt (test amaçlı)

Koşma npm add git+ssh://[email protected]:company/repository.git içinde /app ile döner:

npm ERR! code 128
npm ERR! An unknown git error occurred
npm ERR! command git --no-replace-objects ls-remote ssh://[email protected]/company/repository.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-11-24T00_25_10_559Z-debug.log

Tam olarak aynı komutu çalıştırarak /opt project paketi herhangi bir sorun olmadan doğru şekilde yükler.

Bunu bir alpine docker kutusundan çalıştırıyorum. openssh kurulmuş.

Bu... Dockerfile

FROM node:16.13-alpine

RUN apk add --no-cache openssh-client git python2

RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts && ln -s /run/secrets/ssh_key ~/.ssh/id_rsa && ln -s /run/secrets/ssh_pub_key ~/.ssh/id_rsa.pub

RUN mkdir /app

WORKDIR /app

Birkaç daha bilgilendirici şey

/app # node -v
v16.13.0
/app # npm -v
8.1.4
/app # ssh -T [email protected]
Hi AzaZPPL! You've successfully authenticated, but GitHub does not provide shell access.

package.json

{
    "name": "project",
    "version": "1.0.0",
    "private": true,
    "scripts": {
        "dev": "nuxt",
        "build": "nuxt build",
        "start": "nuxt start",
        "generate": "nuxt generate",
        "generate-schema": "node apollo/generate-schema.js",
        "lint": "eslint --ext .js,.vue --ignore-path .eslintignore .",
        "lintfix": "eslint --fix --ext .js,.vue --ignore-path .eslintignore ."
    },
    "dependencies": {
        "@nuxtjs/apollo": "^4.0.1-rc.4",
        "@nuxtjs/auth": "^4.9.1",
        "@nuxtjs/axios": "^5.12.2",
        "@nuxtjs/dayjs": "^1.2.1",
        "@nuxtjs/style-resources": "^1.0.0",
        "apollo-cache-inmemory": "^1.6.6",
        "copy-to-clipboard": "^3.3.1",
        "core-js": "^3.6.5",
        "date-fns": "^2.19.0",
        "dotenv": "^8.2.0",
        "filepond": "^4.27.1",
        "filepond-plugin-file-validate-type": "^1.2.6",
        "filepond-plugin-image-preview": "^4.6.6",
        "graphql-tag": "^2.11.0",
        "js-file-download": "^0.4.12",
        "jwt-decode": "^3.1.2",
        "lodash": "^4.17.20",
        "nuxt": "^2.14.6",
        "nuxt-buefy": "^0.4.10",
        "nuxt-i18n": "^6.15.4",
        "vee-validate": "^3.4.3",
        "vue": "^2.6.12",
        "vue-filepond": "^6.0.3"
    },
    "devDependencies": {
        "@babel/eslint-parser": "^7.16.3",
        "eslint": "^7.12.1",
        "eslint-config-prettier": "^6.15.0",
        "eslint-loader": "^4.0.2",
        "eslint-plugin-prettier": "^3.1.4",
        "eslint-plugin-vue": "^7.1.0",
        "prettier": "^2.1.2",
        "sass": "^1.32.8",
        "sass-loader": "^12.3.0"
    }
}

Ne herhangi bir fikir oluyor burada?

docker git github node.js
2021-11-24 00:41:33
2
1

Ayarlamak için Docker Dosyanızda deneyin

ENV GIT_SSH_COMMAND='ssh -Tv'

Bu, SSH anahtarınızın neden dikkate alındığına veya dikkate alınmadığına dair size daha fazla ipucu vermelidir npm add.

2021-11-24 08:02:52

En iyi cevabı

1

@Vonc'nin cevabının yardımıyla neler olduğunu anlayabildim.

Günlüklere daha yakından baktığımda, aslında adında bir kullanıcı olduğunu öğrendim node hangi çalıştırırken kullanılır npm. Alpine görüntüsünün Docker dosyasında bu kullanıcı oluşturuluyordu ve npm bu kullanıcı kullanmak için yapılandırılır.

Yani ne oldu, docker konteynerine her giriş yaptığımda oturum açıyordum root kullanıcı ve Docker Dosyasında ayarlanan tüm ssh anahtarları tarafından çalıştırılıyordu. root kullanıcı.

Koşu ssh -T [email protected] işe yaradı çünkü root kullanıcı doğru şekilde ayarlandı, ancak node kullanıcı

Hala kafamı toparlayamadığım şey, komutu neden çalıştırdığımdı? /opt klasör çalışması mı? Her neyse, bu farklı bir gün için bir gizem.

Bu benim güncellenmiş Docker Dosyam. Ssh anahtarlarını şu şekilde ayarladım: node kullanıcı ve oturum açma node kullanıcı

FROM node:16.13-alpine

RUN apk add --no-cache openssh-client git

RUN mkdir /app && chown node:node /app

USER node

RUN mkdir -p -m 0700 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts

RUN ln -s /run/secrets/ssh_key ~/.ssh/id_rsa

WORKDIR /app
2021-11-24 09:02:43

İyi yakaladın, aferin! Upvoted.
VonC

Diğer dillerde

Bu sayfa diğer dillerde

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................