Issue with git dependency on node version upgrade - node.js

I am running a VUE.JS app in a Docker container. The app is currently using node 14.19.0, but I tried upgrading the version to node 15/16.
After changing the node version in the Dockerfile and updating some of the devDependencies, I get an NPM error:
npm ERR! npm ERR! An unknown git error occurred
npm ERR! npm ERR! command git --no-replace-objects ls-remote ssh://git#github.com/[NAMESPACE_PLACEHOLDER]/[REPO_PLACEHOLDER].git
npm ERR! npm ERR! Warning: Permanently added 'github.com' (ECDSA) to the list of known hosts.
npm ERR! npm ERR! git#github.com: Permission denied (publickey).
npm ERR! npm ERR! fatal: Could not read from remote repository.
npm ERR! npm ERR!
npm ERR! npm ERR! Please make sure you have the correct access rights
npm ERR! npm ERR! and the repository exists.
In my package.json file, the repo is loaded with https, not ssh:
"package-name-placeholder": "https://github.com/[NAMESPACE_PLACEHOLDER]/[REPO_PLACEHOLDER].git#v0.1.15"
This exact method is working with Node 14.19.0. I read that there might be an issue with trailing slashes. I tried using them, but the error persists.
Have anyone managed to do something about a similar issue?
Thanks.

Try in your Dockerfile a:
RUN git config --global url."https://${GIT_ACCESS_TOKEN}#github.com".insteadOf "ssh://git#github.com"
(If those repositories are public, you do not need the ${GIT_ACCESS_TOKEN}# part: it would be an ARG GIT_ACCESS_TOKEN passed with a docker build --build-arg GIT_ACCESS_TOKEN=xxx)
You can see here this was reported before:
npm version change in alpine-16's image, and I'm pretty sure that this problem is related to npm version.

Related

Permissions error when trying to install jquery-ui/data

Trying to use React-gridstack on a create-react-app and every time I run the command:
npm i jquery-ui/data
when it asks me to, I get this error:
npm ERR! command failed
npm ERR! command git --no-replace-objects ls-remote ssh://git#github.com/jquery-ui/data.git
npm ERR! Warning: Permanently added 'github.com' (RSA) to the list of known hosts.
npm ERR! git#github.com: 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.```
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
That error is telling you that you either don't have permission to access the repository, this might occur if you're attempting to install a package from a private repository, or that the package you are trying to install does not exist.
In your case the latter is most likely the cause, I assume what you actually want is:
npm i jquery-ui

How can I deploy my meteor app to digital ocean?

I am building an app on the Meteor platform, and my app repository is saved on Github. My server is Digital Ocean. I am trying to deploy commits made in Github to my remote server (website) without success. I tried three approaches, outlined below:
1. I tried executing "git pull" in SSH, but after receiving the message " * branch HEAD -> FETCH_HEAD Already up-to-date" the website remained unchanged.
2. I tried running "mupx", which many recommend for use with Meteor, but I received an error message "Verifying deployment: FAILED".
x Verifying deployment: FAILED
-----------------------------------STDERR-----------------------------------
npm#2, which has some small
npm WARN deprecated backwards-incompatible changes made to `npm run-script` and
npm WARN deprecated semver behavior.
npm ERR! install Couldn't read dependencies
npm ERR! Failed to parse json
npm ERR! Unexpected end of input
npm ERR! File: /bundle/bundle/programs/server/package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file. JSON.parse
npm ERR! System Linux 3.13.0-43-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "i"
npm ERR! cwd /bundle/bundle/programs/server
npm ERR! node -v v0.10.43
npm ERR! npm -v 1.4.29
npm ERR! file /bundle/bundle/programs/server/package.json
npm ERR! code EJSONPARSE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /bundle/bundle/programs/server/npm-debug.log
npm ERR! not ok code 0
=> Redeploying previous version of the app
-----------------------------------STDOUT-----------------------------------
To see more logs type 'mup logs --tail=50'
----------------------------------------------------------------------------
3. I even tried doing "git pull" directly into the Digital Ocean server terminal, but once again received the message " * branch HEAD -> FETCH_HEAD, Already up-to-date. ", once again without any updates to the website.
Does anyone know what I may be doing wrong?
Thank you for your time!

NPM fails to install types

I have a problem with npm install, in that it won't install #types.
This works fine
npm install --save lodash
However asking for types does not
npm install --save #types/lodash
PS C:\Development\Temp> npm install --save #types/lodash
npm WARN `git config --get remote.origin.url` returned wrong result (git://github.com/types/lodash)
npm WARN `git config --get remote.origin.url` returned wrong result (git#github.com:types/lodash)
npm ERR! git clone git#github.com:types/lodash Cloning into bare repository 'C:\Users\myuser\AppData\Roaming\npm-cache\_git-remotes\git-github-com-types-lodash-9eb5372a'...
npm ERR! git clone git#github.com:types/lodash Host key verification failed.
npm ERR! git clone git#github.com:types/lodash fatal: Could not read from remote repository.
npm ERR! git clone git#github.com:types/lodash
npm ERR! git clone git#github.com:types/lodash Please make sure you have the correct access rights
npm ERR! git clone git#github.com:types/lodash and the repository exists.
npm ERR! addLocal Could not install types/lodash
npm ERR! Error: ENOENT: no such file or directory, stat 'C:\Development\Temp\types\lodash'
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! System Windows_NT 10.0.15063
npm ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\ProgramData\\chocolatey\\lib\\npm\\tools\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save" "#types/lodash"
npm ERR! cwd C:\Development\Temp
npm ERR! node -v v8.6.0
npm ERR! npm -v 1.4.9
npm ERR! path C:\Development\Temp\types\lodash
npm ERR! syscall stat
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\Development\Temp\npm-debug.log
npm ERR! not ok code 0
PS C:\Development\Temp>
This has got me scratching my head. I've updated Chocolatey, NodeJS, NPM to make sure their own the latest versions. Tried the commands on empty folders or an existing TypeScript project - thinking it might be getting confused being ran within a Git repository (error: remote.origin.url). Looking at the GitHub URL it makes no sense git://github.com/types/lodash
I took these examples from MSDN Blog - The Future of Declaration Files
Update: I've uninstalled Node.js and tried reinstalling v6.11.3 LTS or v8.6.0. However the #types command still fails.
Update 2: I've realised Chocolately was masking the npm version. I removed the Chocolately folder, and upgraded npm as per #Louis answer.
Upgrade your npm version to version 4 or 5. I'm mentioning 4 because I ran into problems with 5, and using 4 is still viable. I don't know of any good reason to run an older version.
You are using npm version 1.4.9, as shown in this line of the log:
npm ERR! npm -v 1.4.9
The problem is that npm versions prior to version 2 do not support scoped packages. Packages that begin with an # are scoped packages, so #types/lodash is a scoped package. You need npm version 2 or greater to install it. If you were to use the latest npm in the 1.x series (1.4.29), you'd get a better error message:
npm ERR! Error: This version of npm doesn't support scoped packages (caused by reference to #types/lodash). Update to npm#2+.
Version 1.4.9 did not even know that scoped packages were a thing, so it cannot give a nice error message. It looks like it took the # symbol as signifying that the package name is an address and filled in the missing information with Github as the default host.
The upgrade command I typically use to upgrade npm is:
npm install -g npm
You can specify a specific version by replacing the npm argument with one that gives specific version number. npm#4, for instance, would install the latest npm in the 4.x series. If you don't specify a version number, you get the latest released version.

AWS Beanstalk Install Private Github Module via NPM Results In Authentication Issue

I need to install a private github module via npm on an AWS Beanstalk instance.
I'm using a Github personal access token to authenticate with github and access the repo.
My package.json lists the dependency like this:
"privatepackage": "git+https://jaf91ja9jasflkjasf98109asf10asdf:x-oauth-basic#github.com/user123/privatepackage.git"
However, on Beanstalk I get the following error when deploying:
npm ERR! node v0.12.2
npm ERR! npm v2.7.4
npm ERR! code 128
npm ERR! Command failed: git clone --template=/tmp/.npm/_git-remotes/_templates --mirror git#github.com...
npm ERR! Cloning into bare repository '/tmp/.npm/_git-remotes/git-github-com...
npm ERR! Host key verification failed.
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 think you are missing ssh key on your machine and adding same on github.
Please look into generating-ssh-keys which might helps you to resolve this issue.

npm install from git repo fails with ENOENT

I am trying to install one of my own packages as follows
npm install --save gfarrell/state.js
and I'm getting the following errors (full log here):
npm ERR! addLocal Could not install gfarrell/state.js
npm ERR! Error: ENOENT, stat 'gfarrell/state.js'
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! System Darwin 13.4.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "--save" "gfarrell/state.js"
npm ERR! cwd /Users/gideon/Code/PresenceMonitor
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.10
npm ERR! path gfarrell/state.js
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/gideon/Code/PresenceMonitor/npm-debug.log
npm ERR! not ok code 0
Now I've tried various solutions including:
npm cache clean
sudo npm cache clean
rm -rf ~/.npm
sudo npm install --save gfarrell/state.js
npm install --save git://github.com/gfarrell/state.js.git
but nothing has changed the error output. I can't see anything wrong with the module's package.json, and I haven't added anything to my local package.json either. I actually tried installing this package on an earlier version and it worked fine, so I just don't understand what is going wrong.
Needless to say, it's all rather frustrating. Is there something else going on that I'm just not seeing?
This is most probably an authentication issue. You should add --verbose to the install command to se more output. You should see this line in your console output when running with verbose on:
npm ERR! git clone git#github.com:gfarrell/state.js Permission denied (publickey).
Check if you are authenticated to Github using the following command:
ssh -T git#github.com
When you are authenticated correctly you should see the following output:
Hi gfarrell! You've successfully authenticated, but GitHub does not provide shell access.
Github has a great guide on SSH keys as well as how to solve common errors.
Fix your Github authentication and the npm install will start working.
I had a similar issue myself. Because the last "ok" line of the verbose output started with "addRemoteGit", I traced the issue to a function named addRemoteGit in the npm source file cache.js (in v1.4.9, it has now been moved into add-remote-git.js). By adding a call to log.verbose(p), I found out npm could not write to ~/.npm/_git-remotes/.
Basically it was a permission problem: my ~/.npm directory contained files & directories owned by root. I solved the issue by simply running:
sudo find ~/.npm -exec chown $USER:$USER {} \;

Resources