How can I fix the error "ECMDERR Failed to execute "git ls-remote --tags --heads exit code of #128" when running bower install on GitLab CI? - gitlab-ci

I'm installing dependencies using bower in an older project. When running bower install on gitlab ci I get the following error:
ECMDERR Failed to execute "git ls-remote --tags --heads https://github.com/angular/bower-angular-sanitize.git", exit code of #128
What's weird is that it's not always the same repository when the error occurs.
I already tried to set a git user and email, as well rewriting git:// to https://
git config --global user.name "${GITLAB_USER_NAME}"
git config --global user.email "${GITLAB_USER_EMAIL}"
git config --global url."https://".insteadOf git://
According to this Question, error code 128 is a generic error code that is typically thrown by git when it is unable to access a remote repository.
I'm guessing that there are several possible reasons why git might be unable to access repositories here, including network connectivity issues, firewall or proxy restrictions, or the remote repository may be temporarily unavailable. Unfortunately I'm not sure how to debug this.
I'm not using a proxy.
When I run the same command using the same image locally, it works. Can anyone give me some guidance on how to troubleshoot this issue?
Partial output of bower install --json:
, {
"level": "info",
"id": "resolved",
"message": "https://github.com/angular-ui/angular-google-maps.git#065568aa32",
"data": {
"endpoint": {
"name": "angular-google-maps",
"source": "angular-google-maps",
"target": "065568aa32954afa2c9de917542163cd5d3f2b5a"
},
"resolver": {
"name": "angular-google-maps",
"source": "https://github.com/angular-ui/angular-google-maps.git",
"target": "065568aa32954afa2c9de917542163cd5d3f2b5a"
}
}
}
, {
"code": "ECMDERR",
"details": "",
"exitCode": 128,
"data": {
"endpoint": {
"name": "angular-datatables",
"source": "angular-datatables",
"target": "~0.6.x"
},
"resolver": {
"name": "angular-datatables",
"source": "https://github.com/l-lin/angular-datatables.git",
"target": "~0.6.x"
}
},
"id": "ECMDERR",
"level": "error",
"message": "Failed to execute \"git ls-remote --tags --heads https://github.com/l-lin/angular-datatables.git\", exit code of #128\n",
"stacktrace": "Error: Failed to execute \"git ls-remote --tags --heads https://github.com/l-lin/angular-datatables.git\", exit code of #128\n\n at createError (/var/www/.npm/_npx/53/lib/node_modules/bower/lib/util/createError.js:4:15)\n at ChildProcess.<anonymous> (/var/www/.npm/_npx/53/lib/node_modules/bower/lib/util/cmd.js:102:21)\n at ChildProcess.emit (events.js:400:28)\n at maybeClose (internal/child_process.js:1088:16)\n at Process.ChildProcess._handle.onexit (internal/child_process.js:296:5)"
}]
Bower: v1.8.14
Node: v14.21.1

I was running on an older version of Ubuntu, where newer versions of Git weren't available by default. I was able to fix the issue by using the ppa provided on the Download for Linux and Unix page on the git.com website and then upgrading git.
The issue did not occur using the latest version of Git.

Related

Deployment error firebase hosting - 0 files found

Description:
During the deploy of firebase hosting, I received an error stating that 0 files were found. I have included my firebase.json file for reference.
Steps to reproduce:
Run the command firebase deploy --only hosting
Observe the error message stating that 0 files were found
Expected result:
The firebase hosting should be successfully deployed with the specified files.
Actual result:
An error is thrown stating that 0 files were found.
+ hosting: Finished running predeploy script.
i hosting[hosting-project]: beginning deploy...
i hosting[hosting-project]: found 0 files in hosting
+ hosting[hosting-project]: file upload complete
i hosting[hosting-project]: finalizing version...
+ hosting[hosting-project]: version finalized
i hosting[hosting-project]: releasing new version...
+ hosting[hosting-project]: release complete
+ Deploy complete!
Notes:
I have double-checked the file path in the firebase.json file and it
appears to be correct.
I have tried rerunning the deploy command multiple times with the same result
I have also tried deploying a
different project with the same firebase.json file, but the issue
persists.
In my firebase.json file, I am not targeting the dist folder directly because I am using the predeploy script to run npm run lint and npm run build before the deployment. However, I am not ignoring the dist folder with !dist% and !dist/*, which means I am not excluding it from the deployment.
Attached files:
firebase.json
{
"firestore": {
"port": "8080"
},
"functions": [
{
"source": "functions",
"codebase": "default",
"ignore": [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log"
],
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint"
]
}
],
"hosting":{
"public":"hosting",
"ignore": [
"*",
"!dist/",
"!dist/*",
],
"rewrites":[
{
"source":"**",
"destination":"dist/index.html"
}
],
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
]
}
}
I found a solution to resolve the issue of "0 files found" during the deploy of firebase hosting. It may not be the most elegant solution, but it does work. In the "predeploy" section of the hosting configuration, I added ".." at the end of the "npm run lint" and "npm run build" commands to go back to the root folder:
"npm --prefix \"$RESOURCE_DIR\\..\" run lint",
"npm --prefix \"$RESOURCE_DIR\\..\" run build"
This allowed me to target the dist folder directly in the hosting configuration, as specified in the official documentation. Here is the modified hosting configuration:
"hosting":{
"public":"hosting/dist",
"ignore": [
"**/.*",
"**/node_modules/**"
],
"rewrites":[
{
"source":"**",
"destination":"/index.html"
}
],
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\\..\" run lint",
"npm --prefix \"$RESOURCE_DIR\\..\" run build"
]
}
I hope this helps anyone else who may be experiencing the same issue.

How to login to AWS CodeArtifact before npm installs

How can I trigger the login before the install script in node v18.12.1/npm 8.19.2?
I expect the npm preinstall script will run before the install script based on the documentation. When running node v14.21.1/npm 6.14.17 I was able to follow the instructions in this tutorial to trigger a CodeArtifact login with the preinstall script. All packages were installed from my CodeArtifact repository on running npm install as expected.
After updating to node v18.12.1/npm 8.19.2, npm install fails with error:
Unable to authenticate, your authentication token seems to be invalid
What I have tested (each in a fresh environment with no npm cache):
npm run preinstall successfully logs on
∴ AWS credentials are configured and the preinstall script works when executed
npm install fails authentication
npm run preinstall; npm install successfully logs on and installs from CodeArtifact
∴ the preinstall script is not running. I get no results from filtering the debug logs suggesting the co:login step is not run:
$ cat /root/.npm/_logs/2022-12-06T07_12_47_353Z-debug-0.log | grep co:login
$ echo $?
1
After reverting to node v14.21.1/npm 6.14.17, npm install behaves as expected, logging in and installing packages from CodeArtifact.
I have recreated the problem with a minimal package.json which can be tested in a docker container:
docker run --rm -it -v ~/.aws:/root/.aws:ro --name app node:18.12.1 /bin/bash
wget --quiet -O "awscliv2.zip" "https://awscli.amazonaws.com/awscli-exe-linux-$(uname -m).zip" && unzip -q awscliv2.zip
./aws/install
rm awscliv2.zip && rm -r ./aws
Copy files in from a separate terminal
docker cp package.json app:/package.json
docker cp package-lock.json app:/package-lock.json
And then install with npm install in the docker container.
package.json template would require you to substitute your own CodeArtifact repository, domain and owner
{
"name": "app",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"preinstall": "npm run co:login",
"co:login": "aws codeartifact login --tool npm --repository my-repository --domain my-domain --domain-owner 123456789 --region ap-southeast-2"
},
"author": "",
"license": "ISC",
"dependencies": {
"dayjs": "^1.11.6"
}
}
package-lock.json template would require you to substitute your own CodeArtifact url
{
"name": "app",
"version": "1.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "app",
"version": "1.0.0",
"hasInstallScript": true,
"license": "ISC",
"dependencies": {
"dayjs": "^1.11.6"
}
},
"node_modules/dayjs": {
"version": "1.11.6",
"resolved": "https://mydomain-123456789.d.codeartifact.ap-southeast-2.amazonaws.com:443/npm/my-repository/dayjs/-/dayjs-1.11.6.tgz",
"integrity": "sha512-zZbY5giJAinCG+7AGaw0wIhNZ6J8AhWuSXKvuc1KAyMiRsvGQWqh4L+MomvhdAYjN+lqvVCMq1I41e3YHvXkyQ=="
}
},
"dependencies": {
"dayjs": {
"version": "1.11.6",
"resolved": "https://mydomain-123456789.d.codeartifact.ap-southeast-2.amazonaws.com:443/npm/my-repository/dayjs/-/dayjs-1.11.6.tgz",
"integrity": "sha512-zZbY5giJAinCG+7AGaw0wIhNZ6J8AhWuSXKvuc1KAyMiRsvGQWqh4L+MomvhdAYjN+lqvVCMq1I41e3YHvXkyQ=="
}
}
}

npm react-scripts start failed to compile: modules not found

I work on a API on Docker. When i launch my app via the command "npm react-scripts", i have a "failed to compile" message and "Module not found: Can't resolve 'src/containers/App'".
Here is the content of my jsconfig.json:
{
"target": 2020,
"compilerOptions": {
"baseUrl": "./src"
}
}
If anyone has a way to fix it ?.
Thank you.

Facing vulnerability security issue for dot-prop when updating to latest npm package

I am trying to update npm version to latest 6.14.7 in package.json.
After updating npm to the latest, I ran npm audit and got two vulnerabilities for the dot-prop package dependency which is showing under npm path.
So, I tried updating the latest dot-prop ^5.1.1. But still getting the same error.
Please help me with this how can I manually review and fix.
Audit Report:
[root#redhatdev client]# npm audit
=== npm audit security report ===
Manual Review
Some vulnerabilities require your attention to resolve
Visit https://go.npm.me/audit-guide for additional guidance
High Prototype Pollution
Package dot-prop
Patched in >=5.1.1
Dependency of npm [dev]
Path npm libnpx update-notofoer configstore dot-prop
More info https://npmjs.com/advisories/1213
High Prototype Pollution
Package dot-prop
Patched in >=5.1.1
Dependency of npm [dev]
Path npm update-notofoer configstore dot-prop
More info https://npmjs.com/advisories/1213
found 2 high severity vulnerabilities in 1674 scanned packages
2 vulnerabilities require manual review. See the full report for details.
[root#redhatdev client]#
Full Audit report: npm audit --json
{
"actions": [
{
"action": "review",
"module": "dot-prop",
"resolves": [
{
"id": 1213,
"path": "npm>libnpx>update-notifier>configstore>dot-prop",
"dev": true,
"optional": false,
"bundled": true
},
{
"id": 1213,
"path": "npm>update-notifier>configstore>dot-prop",
"dev": true,
"optional": false,
"bundled": true
}
]
}
],
"advisories": {
"1213": {
"findings": [
{
"version": "4.2.0",
"paths": [
"npm>libnpx>update-notifier>configstore>dot-prop",
"npm>update-notifier>configstore>dot-prop"
]
}
],
"id": 1213,
"created": "2019-10-14T17:43:55.291Z",
"updated": "2020-07-29T20:58:02.206Z",
"deleted": null,
"title": "Prototype Pollution",
"found_by": {
"link": "",
"name": "Unknown",
"email": ""
},
"reported_by": {
"link": "",
"name": "Unknown",
"email": ""
},
"module_name": "dot-prop",
"cves": [
"CVE-2020-8116"
],
"vulnerable_versions": "<5.1.1",
"patched_versions": ">=5.1.1",
"overview": "Versions of `dot-prop` before 5.1.1 are vulnerable to prototype pollution. The function `set` does not restrict the modification of an Object's prototype, which may allow an attacker to add or modify an existing property that will exist on all objects.\n\n",
"recommendation": "Upgrade to version 5.1.1 or later.",
"references": "- [GitHub advisory](https://github.com/advisories/GHSA-ff7x-qrg7-qggm)\n- [CVE](https://nvd.nist.gov/vuln/detail/CVE-2020-8116)",
"access": "public",
"severity": "high",
"cwe": "CWE-471",
"metadata": {
"module_type": "",
"exploitability": 4,
"affected_components": ""
},
"url": "https://npmjs.com/advisories/1213"
}
},
"muted": [],
"metadata": {
"vulnerabilities": {
"info": 0,
"low": 0,
"moderate": 0,
"high": 2,
"critical": 0
},
"dependencies": 61,
"devDependencies": 1612,
"optionalDependencies": 31,
"totalDependencies": 1674
},
"runId": "9b99170c-35c0-44b1-a0e6-8b714069a255"
}
Edit 2:
Now I found the Problem.
You updated npm locally. (it's in your package.json)
So please run:
npm uninstall npm --save (uninstall locally)
then:
npm i npm -g (that updates npm globally and not locally)
That fixes the problem.
Rest of this answer is obsolete and doesn't add to the solution.
EDIT:
It seems to be a npm problem to me.
Here is what I did:
I had npm version 6.14.6.
I installed dot-prop.
No Problem.
I updated my npm to6.14.7.
2 vulnerabilities.
I ran npm audit fix which results in fixed 0 of 2 vulnerabilities.
I ran npm -v which results in 6.14.6.
So I think it's a problem with npm 6.14.7 (and/or a combination with this special package)
Original Message:
did you also try npm audit fix ?
Also it says https://go.npm.me/audit-guide for additional guidance
Did you try that as well?

building serialport.js with nw.gyp for nw.js

I'm trying to package serialport.js with my nw.js app. I'm having a hard time building serialport.js for nw.js.
I've installed serialport.js in my "app\resource\node_modules" using npm.
I've also installed nw.gyp globally "npm install nw-gyp -g"
Then I changed directory to "app\resource\node_modules\serialport" where the binding.gyp is located and tried to rebuild serialport with nw-gyp "nw-gyp rebuild --target=0.12.3"
This is the error I got:
Undefined variable module_name in binding.gyp
Any Ideas how I can get passed this problem?
Other's seem to have similar problems:
Serialport.js in Node-webkit (nw.js) on Win 7
I also saw the same error happening with a different node module:
Building node-sqlite3 with nw-gyp
open node_modules/serialport/binding.gyp, you need make some changes...
before:
"target_name": "action_after_build",
"type": "none",
"dependencies": [ "<(module_name)" ],
"copies": [
{
"files": [ "<(PRODUCT_DIR)/<(module_name).node" ],
"destination": "<(module_path)"
after:
"target_name": "action_after_build",
"type": "none",
"dependencies": [ "serialport" ],
"copies": [
{
"files": [ "<(PRODUCT_DIR)/serialport.node" ],
"destination": "."
And change module_path in node_modules/serialport/package.json for:
"module_path": "./build/{configuration}/",
Finally, run nw-gyp rebuild --target=0.12.3
Downgrading npm works! Give a try
npm install npm#6 -g