Unable to install node module from git repository in CirlcleCI - node.js

Following is the scenario
ParentNodeModule in a git repo which consumes ChildNodeModule from another get repo and refers it in package dependency as git+ssh://git#github.com/SomeOrg/ChildNodeModule.git#1.0.0.
Now problem is that ParentNodeModule as a circle ci setup which should run tests and lint checks but its not able to because in cirlce ci its no able to access git#github.com/SomeOrg/ChildNodeModule.git and showing following error
npm ERR! ERROR: Permission to SomeOrg/ChildNodeModule.git denied to deploy key
npm ERR! fatal: Could not read from remote repository.
n
So how to solve it any clues would be helpful

Within CircleCI, you should grant access to the SomeOrg/ChildNodeModule project so that CircleCI can read that repository. CircleCI will automate this process by adding a Deploy Key to that repository.

Related

NPM Authentication Error To Private Repo on jenkins build

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.

How to set up Travis CI to use linked (local) packages?

I use npm link myDependency within myPackage so that I can work on both at the same time (vs. publishing myDependency after every change and then updating myPackage to test it.)
I would like to be able to use Travis CI with myPackage but, as one could expect (I actually forgot, but it became quite obvious after attempting to build): running npm install on Travis won't manage to install the linked package.
So, what can I do? I saw someone suggest using a Docker container but that feels like a lot of infrastructure and I'm not experienced with Docker. Another option I thought of was adding a pre-install script to clone the dev branch of myDependency repo into the node_modules folder.
First though, I'm sure I'm not the first person who ever worked on two packages alongside each other, so there must be some consensus on how this should be done.
I solved this by replicating my development set-up on Travis.
The key to solving this involves giving Travis a way to access GitHub. To do this, log in to GitHub and go to the Personal access tokens page.
You’ll see a form with a field for the name of your token and what permissions you want to grant access to. Fill in a name such as "Travis CI Pull Repo" and select the "repo" section. None of the others are necessary, so no need to give access to them. At the bottom of the page is a green button "Generate token."
Back in your code editor, create a .travis.yml file in the root directory of your project if you don’t have one already. We will be using a RubyGem for the next step, so if you don’t have Ruby gems installed, you’ll need to download it. You can check if you have it installed by running gem -v in the terminal.
If you do, run the following in the terminal to install the Travis RubyGem:
gem install travis
Next, in the terminal, make sure you’re working in your project’s root directory, and use the Travis gem to add the access token to your .travis.yml file:
travis encrypt GH_TOKEN="token-from-github-goes-here" --add
If you were successful, your .travis.yml file should have a bunch of random text an encrypted token saved:
env:
global:
secure: "lots-of-seemingly-random-characters"
That’s it! Travis should now be able to pull (and push if that’s what you’re into) to your GitHub repository.
Obviously your .travis.yml file can vary greatly from mine, but at it’s most basic, I set up .travis.yml like this:
language: node_js
node_js:
- '6'
cache:
directories:
- node_modules
install:
- npm install
script:
- npm run lint
- npm run test
env:
global:
secure: "lots-of-seemingly-random-characters"
To add the cloning and linking of the dependency, add a before_install section with the following commands:
before_install:
- git config credential.helper "store --file=.git/credentials"
- echo "https://${GH_TOKEN}:#github.com" > .git/credentials
- cd ..
- git clone https://github.com/my-name/my-dependency.git my-dependency
- cd my-dependency
- npm install
- npm link
- cd ../my-main-project
What is this actually doing?
We configure Git to use our saved access token.
We go one directory up and clone the repository into a new folder with the same name as the repository.
We go into the repository and install its dependencies.
We create a global NPM link.
Finally, we return to the main project (the one we are running Travis on). Note that this name must match the repository’s name on GitHub as that’s the name Travis will use.
In addition, we’ll need to actually use the link created above, so in the install section add the following line:
install:
- npm install
- npm link my-dependency
Make sure you put npm link after npm install as by default npm install will obliterate any links (a very annoying bug for those of us who use npm link).

NPM update error - Fails to execute GIT

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:

Git auth failing when running npm install as sudo

I am trying to install an npm package that pulls from our private repo. When I run npm install as myself, I get Please try running this command again as root/Administrator. When I run it as sudo, I get
npm ERR! Error: Command failed: 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.
I normally don't use sudo to do npm install. I think the issue is that when I run as sudo, it is looking in /var/root/.ssh for the key. I don't have the root user credentials, otherwise I would create a new key as root. Is there another work around?
EDIT: tried the suggestions below, they didn't work. However, the repo in questions is referenced by a dependency below the package root. `./node_modules//package.json. If I change the git url to use http, it works, but it's not a good idea to do it this way because I'll have to change it when I check the package back into the repo.
Try this:
sudo /bin/bash then, run your npm command
I think the issue is that when I run as sudo, it is looking in /var/root/.ssh for the key. I don't have the root user credentials
A workaround would be to change the url of that repo to an http one: it would then query for your login/password instead of relying on ssh keys which you cannot provide as root.
cd /path/to/private/repo
git remote set-url origin https://server/user/repo
If I change the git url to use http, it works, but it's not a good idea to do it this way because I'll have to change it when I check the package back into the repo.
Actually, you can change an url by another without modifying the config of the remote url.
For instance (as in How to use SSH instead of HTTP for Git submodules?)
git config url.https://github.com/.insteadOf ssh://git#github.com/
# or
git config url.https://github.com/.insteadOf git#github.com:

AWS Elastic Beanstalk Node.js npm install error

During the deployment of an application, npm install is unable to install a very particular dependency:
npm ERR! enoent ENOENT: no such file or directory, chmod '/tmp/deployment/application/node_modules/babel-core/node_modules/regexpu/node_modules/regjsparser/node_modules/jsesc/bin/jsesc'
I was able to find that above error by ssh'ing into the particular EC2 instance hosting my Node application and running npm install via the command below:
sudo /opt/elasticbeanstalk/containerfiles/ebnode.py --action npm-install 2
Then follows with this generic failure:
Failed to run npm install. Snapshot logs for more details.
No environment variable EB_EVENT_FILE found. Writing message to stderr.
Msg: Failed to run npm install. Snapshot logs for more details.
What's weird is that I've been able to deploy successfully once before, and am using the same exact configurations for that previous deployment. My only command is npm start within .ebextensions/.
Within my package.json, I changed all dev dependencies into dependencies, as webpack is building during prestart.
This all builds and runs locally, by the way. Also I'm using Node 4.2.1 and npm 2.14.7 on EB.
Any help would be awesome. Thanks!
I ended up just creating and deploying a Docker container to solve this issue. Deploying to the environment provided by EB is too nondeterministic - the dependency tree wasn't created correctly.

Resources