NPM update error - Fails to execute GIT - node.js

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:

Related

Could not install from "node_modules/eth-sig-util/ethereumjs-abi#git+https:/github.com/ethereumjs/ethereumjs-abi.git"

I deleted the .next and node_modules folder (just experimenting) and then tried executing npm i. I got the following error:
$ npm i
npm ERR! code ENOLOCAL
npm ERR! Could not install from "node_modules/eth-sig-util/ethereumjs-abi#git+https:/github.com/ethereumjs/ethereumjs-abi.git" as it does not contain a package.json file.
Any resolution?
So, the culprit was dirty package-lock.json file. I just reset my repo using git reset --hard so that the package-lock.json comes to the last working state. (PLEASE USE git reset --hard WITH CAUTION; advisable to stash the WIP using git stash first!)
After this, running npm i gave no error.
look at this link.
https://www.npmjs.com/package/ethereumjs-abi
You can use this command.
npm i ethereumjs-abi

Unable to install node module from git repository in CirlcleCI

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.

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.

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:

npm doesn't honor git's "insteadOf" config when cloning from mirrors

I have set up the following command to prevent npm from downloading NPM packages with the GIT protocol, as it is somehow blocked by my server :
git config --global url."https://github.com/".insteadOf git#github.com
However, when running npm install, an error still occurs because a package tries to use the Git protocol, in the context of repo cloning from a mirror :
npm ERR! git clone --template=/home/jenkins/.npm/_git-remotes/_templates --mirror git://github.com/isaacs/js-yaml.git /home/jenkins/.npm/_git-remotes/git-github-com-isaacs-js-yaml-git-dd3d7a8b: Cloning into bare repository '/home/jenkins/.npm/_git-remotes/git-github-com-isaacs-js-yaml-git-dd3d7a8b'...
npm ERR! git clone --template=/home/jenkins/.npm/_git-remotes/_templates --mirror git://github.com/isaacs/js-yaml.git /home/jenkins/.npm/_git-remotes/git-github-com-isaacs-js-yaml-git-dd3d7a8b:
npm ERR! git clone --template=/home/jenkins/.npm/_git-remotes/_templates --mirror git://github.com/isaacs/js-yaml.git /home/jenkins/.npm/_git-remotes/git-github-com-isaacs-js-yaml-git-dd3d7a8b: fatal: unable to connect to github.com:
npm ERR! git clone --template=/home/jenkins/.npm/_git-remotes/_templates --mirror git://github.com/isaacs/js-yaml.git /home/jenkins/.npm/_git-remotes/git-github-com-isaacs-js-yaml-git-dd3d7a8b: github.com[0: 192.30.252.129]: errno=Connection refused
I compared the modules that were installed into node_modules and the one that are declared in package.json, and the only missing one is grunt-contrib-nodeunit, which strangely doesn't depend on js-yaml... So why does it want to clone its repo then ? In any case, is there a way to force using HTTPS when specifying mirrors ?
I was able to get around this using (git:// instead of git#)
git config --global url."http://github.com".insteadOf git://github.com
I could not get around this problem with Gitlab CI. For some reason npm won't use my insteadOf rule, even though nothing is printed on the logs.
My solution is to edit the original file directly using sed :
sed -i -e "s/ssh\:\/\/git\#myrepo\.com\:/https\:\/\/myrepo\.com\//g" package.json
This will replace all ssh://git#myrepo.com: with https://myrepo.com/ (note the trailing : is replaced by /).

Resources