I would like to run the CI part of my Node / Ionic project where I just yesterday added a custom capacitor plugin - repo A.
This plugin sits in repo B.
On my dev machine I added B as
npm install https://PERSONAL_ACCESS_TOKEN#github.com/ME/B.git --save
to project A.
package.json now contains
"B": "git+https://PERSONAL_ACCESS_TOKEN#github.com/ME/B.git",
and I pushed this to my current merge request.
However, the CI pipeline is telling me now:
npm install
shell: /usr/bin/bash -e {0}
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t https://***#github.com/ME/B.git
npm ERR!
npm ERR! remote: Repository not found.
npm ERR! fatal: repository 'https://github.com/ME/B.git/' not found
npm ERR!
Project B is a private repo. My account owns both repos and I am using my newly created Personal Access Token.
What should I check? I can pull the repo on my local, but there I am setup with my git+ssh env credentials too, so it might work just because of that...
Check first if you need your GitHub username:
https://myGitHubUsername:PERSONAL_ACCESS_TOKEN#github.com/ME/B.git
^^^^^^^^^^^^^^^^^
Then, if you need the token in the git+https URL:
"How to use private GitHub repo as npm dependency" mentions the use of npm-cli-login instead:
- name: Login to GitHub private NPM registry
env:
CI_ACCESS_TOKEN: ${{ secrets.NAME_OF_YOUR_ACCESS_TOKEN_SECRET }}
shell: bash
run: |
npm install -g npm-cli-login
npm-cli-login -u "USERNAME" -p "${CI_ACCESS_TOKEN}" -e "EMAIL" -r "https://npm.pkg.github.com" -s "#SCOPE"
Most answers that I have seen to install private GitHub repo
"package": "git+https://PERSONAL_ACCESS_TOKEN:x-oauth-basic#github.com/username/packge.git"
or
"package": "https://PERSONAL_ACCESS_TOKEN:x-oauth-basic#github.com/username/packge.git"
This works in local, however, if you are using actions/checkout#v2 in your github Action then you need to use persist-credentials:false like the following.
- uses: actions/checkout#v2
with:
persist-credentials: false
otherwise, you'll get an error message remote: Repository not found.
other ways to install private github repo
if you are using ssh like following
"package": "git+ssh://git#github.com/username/packge.git"
then you have to use the ssh-agent in your github action like this
- uses: webfactory/ssh-agent#v0.5.4
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
here SSH_PRIVATE_KEY is a private key from public-private key pair generated using ssh-keygen and the public key is added as a deploy key in the private repo that you are trying to install as an npm package. for more information about this, you can check the official doc
Related
I've created a action for a deployment on github actions. This all works with composer install and git pulling the master branch. However on my digital ocean droplet, I get the issue
bash: line 4: npm: command not found
If i ssh into my server i can use npm perfectly fine. This was installed via nvm and uses the latest version but for some reason its not accessable via the action.
My deployment script is
on:
push:
branches: [master]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy Laravel APP
uses: appleboy/ssh-action#v0.1.4
with:
host: ${{secrets.SSH_HOST}}
key: ${{secrets.SSH_KEY}}
username: ${{ secrets.SSH_USER }}
script: |
cd /var/www/admin
git pull origin master
composer install
npm install
npm run prod
I presume this is more to do with the setup from nvm as i can use this via ssh but as they use the same user to log in via ssh, i can't seem to see an issue.
Any ideas how I can resolve this issue to give access/allow github actions to use npm?
I didn't find a solution for the nvm issue, installing npm via a different way resoleved this issue.
I had the same issue, and finally found the solution.
I could solve the issue by adding the following lines before running npm commands.
export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh
These commands helps the terminal fix the node path installed by nvm.
Reference link is here.
I'm trying to push a npm artifact and have it stored in Gitlab in its "Package Repositories" but am having trouble. Have tried a few different ways, with all giving the same error.
The below mostly comes from How do I publish a private npm package with gitlab ci?, and this is my .gitlab-ci.yml file
image: node:latest
stages:
- deploy
deploy:
stage: deploy
script:
- npm install
- npm config set //gitlab.com//api/v4/projects/700/packages/npm/:_authToken ${CI_JOB_TOKEN}
- npm publish
But then gets an error of need auth You need to authorize this machine using npm adduser
I then run npm adduser, but that gets an error of Username: npm ERR! cb() never called!
And here is part of the package.json:
"publishConfig": {
"#foo:registry":"https://gitlab.com/api/v4/projects/700/packages/npm"
},
Another method I try is doing not doing the npm config set..., but instead doing echo "//gitlab.com//api/v4/projects/700/packages/npm/:_authToken=${CI_JOB_TOKEN}">.npmrc, but that gets the same errors.
And yet another method I try is not having npm config nor echo //..., but having this in the .npmrc:
#foo:registry=https://gitlab.com/api/v4/projects/700/packages/npm
//gitlab.com/api/v4/projects/700/packages/:_authToken=${CI_JOB_TOKEN}
But even that has the same errors.
Go through the troubleshooting steps that Gitlab provides.
https://docs.gitlab.com/ee/user/packages/npm_registry/index.html#publish-an-npm-package-by-using-cicd
I am always getting an error on npm install after setting NPM Authenticate. I would like to authenticate to my npm private registry during image build and install all the dependencies I need. Maybe I misunderstood how this authentication process works but this is what I am doing:
Build pipeline
I tried establishing a service connection from the project settings page as in Service connections for builds and releases
After that, I also set up my NPM Authentication task following the steps in With a Task Runner (e.g. make gulp work)
But this is not working. These are the errors I am getting:
During 'NPM Authenticate' phase:
[warning]Found and overrode credentials for the
myregistry.pkgs.visualstudio.com registry in the selected .npmrc file.
Remove credentials from the file and store them in an npm service
connection instead (recommended), or remove the npm Authenticate task
from your build to use credentials checked into an .npmrc.
During 'Build an Image' phase:
Step 4/7 : RUN npm install --production ---> Running in 8724f713f1db
[91mnpm ERR! code[0m[91m E404 [0m[91mnpm [0m[91mERR! 404[0m[91m Not
Found: #myregistry/service-logging#latest npm ERR![0m[91m A complete
log of this run can be found in: npm ERR!
/root/.npm/_logs/2018-09-11T04_20_00_513Z-debug.log [0mThe command
'/bin/sh -c npm install --production' returned a non-zero code: 1
[error]The command '/bin/sh -c npm install --production' returned a non-zero code: 1 [error]/usr/local/bin/docker failed with return
code: 1 [section]Finishing: Build an image
This is my .npmrc file:
unsafe-perm=true
package-lock=false
registry=https://myregistry.pkgs.visualstudio.com/_packaging/myregistry/npm/registry/
always-auth=true
//myregistry.pkgs.visualstudio.com/_packaging/myregistry/npm/registry/:_authToken=${NPM_TOKEN}
//myregistry.pkgs.visualstudio.com/_packaging/myregistry/npm/:_authToken=${NPM_TOKEN}
And this is my Dockerfile:
FROM node:8.9-alpine
ARG NPM_TOKEN
WORKDIR /usr/src/srv/
COPY package.json package.json
COPY .npmrc .npmrc
RUN npm install --production
RUN rm -f .npmrc
COPY . .
EXPOSE 8080
CMD npm start
Any help to unblock me from this issue will be highly appreciated! Thanks!
I finally resolved this issue in my pipeline by removing the last two lines in my .npmrc file. the last line was causing an issue. After the NPM Authenticate task, my .npmrc file was being modified to:
unsafe-perm=true
package-lock=false
registry=https://myregistry.pkgs.visualstudio.com/_packaging/myregistry/npm/registry/
always-auth=true
//myregistry.pkgs.visualstudio.com/_packaging/myregistry/npm/:_authToken=${NPM_TOKEN}
//myregistry.pkgs.visualstudio.com/_packaging/myregistry/npm/registry/:username=VssToken
//myregistry.pkgs.visualstudio.com/_packaging/myregistry/npm/registry/:_password=***
//myregistry.pkgs.visualstudio.com/_packaging/myregistry/npm/registry/:email=VssEmail
//myregistry.pkgs.visualstudio.com/_packaging/myregistry/npm/registry/:always-auth=true
Somehow, the following config was being taken into consideration and the config the NPM Authenticate inserted was being ignored, causing the pipeline error:
//myregistry.pkgs.visualstudio.com/_packaging/myregistry/npm/:_authToken=${NPM_TOKEN}
Also, no need to include the following line since NPM Authenticate will do the job for you:
//myregistry.pkgs.visualstudio.com/_packaging/myregistry/npm/registry/:_authToken=${NPM_TOKEN}
By removing the line above, this warning disappeared:
[warning]Found and overrode credentials for the
myregistry.pkgs.visualstudio.com registry in the selected .npmrc file.
Remove credentials from the file and store them in an npm service
connection instead (recommended), or remove the npm Authenticate task
from your build to use credentials checked into an .npmrc.
So, to conclude, just keep your .npmrc file as simple as this:
unsafe-perm=true
package-lock=false
registry=https://myregistry.pkgs.visualstudio.com/_packaging/myregistry/npm/registry/
always-auth=true
Everything was fine with the Dockerfile.
I encountered this recently, Posting what I found out here in case it helps folks (or myself) in the future.
I was trying to authenticate against a private NPM feed during an Azure DevOps Pipeline build using the NpmAuthenticate task runner.
My initial pipeline looked like this:
- task: npmAuthenticate#0
displayName: Authenticate Npm Feed
inputs:
workingFile: './source/WebApplication/.npmrc'
customEndpoint: ExternalFeedServiceConnection
- task: Npm#1
inputs:
command: 'install'
workingDir: ./source/WebApplication #path to package.json
customRegistry: 'useNpmrc'
displayName: Install NPM Packages
The Npm#1 task would continually fail with a login error. No matter what permutation was attempted. What finally worked was replacing it with a script step instead:
- script: 'npm install'
workingDirectory: ./source/WebApplication
displayName: npm install
The script step appears to be executing the exact same command as the Npm#1 task, but is able to authenticate fine.
The npmAuthenticate azure devops task documentation vaguely suggests this, but it's unclear why it would work with a script step but not the Npm#1 task.
You need to include the token in .npmrc file or update this file before run npm install command.
I'm working on a Front End Application that relies on a dependency developed by our organization but is hosted in a separate repository. It's a bitbucket repo hosted by us and is private.
We're using NPM to manage this dependency, and install it via git+https://<the-dependency-repo>.com
This works in our local environment because our credentials are cached. Please note: WE CANNOT SWITCH TO SSH. I'm aware of the ssh solution, I have no control over account management, bitbucket access etc...
When the Jenkins CI runs, it pulls our application from it's repository using credentials stored in the Credentials Plugin, and runs npm install.
The Problem:
The install fails because of authentication failure during the npm install.
What I've tried so far:
Since the git credentials are stored in the Jenkins Credential Plugin, I have access to a git username/password combination.
The precise failure happens when npm attempts to run git ls-remote ...
To circumvent this authentication failure, I am able to run a shell command before the npm install:
git config credential.helper 'cache'
git fetch https://${USERPASSCOMBO}#<repo>
The good news is that this works! NPM is able to run git fetch ls-remote without error
The bad news is that the next command git clone -q <repo> fails.
I've attempted the same solution: adding the following prior to npm install:
git config credential.helper 'cache'
git ls-remote https://${USERPASSCOMBO}#<repo>
git clone https://${USERPASSCOMBO}#<repo>
note: these commands work as expected, prior to npm install
NPM install still fails however, producing the following error output:
[ERROR] npm ERR! Command failed: /bin/git clone -q https://<repo> /var/lib/jenkins/.npm/_cacache/tmp/git-clone-ed5ac1a9
[ERROR] npm ERR! warning: templates not found /tmp/pacote-git-template-tmp/git-clone-49feabe4
[ERROR] npm ERR! fatal: Authentication failed for '<repo>'
[ERROR] npm ERR!
Any help is greatly appreciated, even a pointer towards the right direction. I've exhausted trying everything I can think of.
Try installing from the repository with the URL git+https://user:password#<repo-url>.
Note that this leaves your password out in the open, so I suggest generating an app token or similar if your repository provider supports this.
When I try to create a project I get the error below.
It seems to be network related because it occurs only in company network.
Any idea how to troubleshoot that?
D:\Projects\aurelia>au new test3
. . .
Installing project dependencies. npm ERR! git clone
--template=C:\Users\user\AppData\Roaming\npm-cache_git-r emotes_templates --mirror git://github.com/gulpjs/gulp.git
C:\Users\AppData\Roaming\npm-cache_git-remotes\git-github-com-gulpjs-gulp-git-4-0ecf98f08
: npm ERR! git clone
--template=C:\Users\user\AppData\Roaming\npm-cache_git-remotes_templates --mirror https://github.com/gulpjs/gulp.git
C:\Users\user\AppData\Roaming\npm-cache_git-remotes\git-https-github-com-gulpjs-gulp-git-40-4b46db44: npm ERR! git clone
--template=C:\Users\user\AppData\Roaming\npm-cache_git-remotes_templates --mirror git#github.com:gulpjs/gulp.git
C:\Users\user\AppData\Roaming\npm-cache_git-remotes\git-github-com-gulpjs-gulp-git-4-0-7c06e801:
UPDATE
This what I get when I run npm install
If I copy paste the git command that fails I get this:
error: SSL certificate problem, verify that the CA cert is OK.
Details:error:14090086:SSL
routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed while
accessing https://github.com/gulpjs/gulp.git/info/refs fatal: HTTP
request failed
UPDATE
I added the missing certificate to git, and now I can run the git command by itself successfully. If I run npm install I still get an error.
I also followed the advice of #Andrew and modified the git config file.
Try configuring your git to use https instead of git. That seems to work more frequently inside work networks.
Type this command into your console:
git config --global url."https://".insteadOf git://
Then you can try to create the project again, or just run npm install if it's already been created and it just failed on the dependency retrieval step.
Additionally, if that doesn't work, you might need to further specify when npm is using git with ssh. In this case, run this command as well:
git config --global url."https://github.com/".insteadOf git#github.com: