Estoy tratando de usar mi primer paquete npm privado en una instancia privada de gitlab
@ajouve:registry=https://gitlab.my-website.io/api/v4/packages/npm/ a .npmrc
el comando npm get parece devolver la configuración correcta
; "project" config from /Volumes/Work/service/.npmrc @ajouve:registry = "https://gitlab.my-website.io/api/v4/packages/npm/" ; "cli" config from command line options omit = [] user-agent = "npm/7.5.4 node/v12.18.1 darwin x64" ; node bin location = /usr/local/bin/node ; cwd = /Volumes/Work/service ; HOME = /Users/ajouve ; Run `npm config ls -l` to show all defaults.Pero cuando quiero agregar el paquete
npm install --save @ajouve/my-module
tengo
npm ERR! code E404 npm ERR! 404 Not Found - GET https://registry.npmjs.org/@ajouve/my-module Not found npm ERR! 404 npm ERR! 404 '@ajouve/my-module@*' is not in the npm registry. npm ERR! 404 You should bug the author to publish it (or use the name yourself!) npm ERR! 404 npm ERR! 404 Note that you can also install from a npm ERR! 404 tarball, folder, http url, or git url. npm ERR! A complete log of this run can be found in: npm ERR! /Users/ajouve/.npm/_logs/2021-03-19T15_06_50_186Z-debug.logVa a https://registry.npmjs.org
Ejecutando npm config ls -l | grep registry
tengo
metrics-registry = "https://registry.npmjs.org/" registry = "https://registry.npmjs.org/" @ajouve:registry = "https://gitlab.my-website.io/api/v4/packages/npm/"En lugar de git://, usa git+ssh://
npm i -S git+ssh://git@gitlab.com:<org>/<project>.gitAquí puedes obtener varias respuestas.
Instale el módulo npm desde el repositorio privado de gitlab
Como alguien que comenzó a usar el registro de Gitlab hace un par de días, me encontré con el mismo problema. En .npmrc, el nombre del alcance debe coincidir con el alcance de su paquete. Por ejemplo, si tenemos el proyecto A, su paquete.json debería ser así:
{ "name": "@myscope/myproject", ...Rest of your package.jsonY en su proyecto B, el .npmrc debe coincidir con el alcance
@myscope:registry=https://gitlab.com/api/v4/packages/npm/Luego, asegúrese de autenticarse con el registro de alcance, de lo contrario, NPM arrojará un error o lo ignorará y buscará en el Registro de NPM.
$ npm config set @myscope:registry https://gitlab.com/api/v4/packages/npm/ $ npm config set -- '//gitlab.com/api/v4/packages/npm/:_authToken' "<your_token>"NOTA: <su_token> debe ser un token de acceso creado en su perfil de Gitlab. Puede crear esto yendo a Preferencias > Tokens de acceso. Asegúrese de verificar "read_registry" antes de crear el token.
Luego, puede instalar su paquete fácilmente
$ npm install --save @myscope/myprojectEDITAR: si está utilizando una instancia de gitlab autohospedada, sigue lo mismo, solo recuerde cambiar "gitlab.com" a la URL de su instancia de gitlab.
Prueba esto, debería funcionar.
npm install --save @ajouve/my-module --registry=https://gitlab.my-website.io/api/v4/packages/npm/Otra forma es crear un punto final de grupo en la instancia privada que apuntará el proxy alojado + a los paquetes públicos y actualizará su registro para apuntar a ese punto final para que funcionen tanto los paquetes privados como los públicos.