Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot install with npm package from git

I am trying to install package from git, which I forked earlier.

I try

npm i catsaredoomed/invest-openapi-js-sdk --save-dev

I've got

npm ERR! prepareGitDep 2> npm WARN install Usage of the `--dev` option is deprecated. Use `--also=dev` instead.

Moreover, this error even don't depend on flag I provided. I can set --save or don't provide at all, it persists anyway. Surely, --also=dev doesn't change this situation

UPD: npm -v 6.14.13

UPD 2:

It appears npm for whatever reason needs sudo to run this command (I didn't use sudo with npm any times before and all other packages for app were installed without sudo). So with sudo this command runs, but only to make new error

    npm ERR! command git --no-replace-objects ls-remote ssh://[email protected]/catsaredoomed/invest-openapi-js-sdk.git
npm ERR! [email protected]: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.

For whatever reason when asking for public (!) repo it needs key

UPD 3: NodeJS (with npm) is installed through sudo dnf as Fedora module, git as usual sudo dnf install, nothing special

like image 768
catsaredoomed Avatar asked Dec 17 '25 08:12

catsaredoomed


2 Answers

For whatever reason when asking for public (!) repo it needs key

But... An SSH URL would always require a public key in order to authenticate the user first, and then access the repository (which will be granted, since the repository is public).

If SSH is an issue, try one of those commands:

git config --global url."https://github.com/".insteadOf ssh://[email protected]/
# or:
git config --global url."https://github.com/".insteadOf [email protected]:
# or even:
git config --global url."https://".insteadOf ssh://

That way, the npm command will use HTTPS URLs instead of SSH ones.

Note the last command would affect any host, not only GitHub.
Keep the GitHub-specific lines above if you only want to fix npm/GitHub.

Verify what is set with:

git config --global --get-all url."https://github.com/".insteadof

This all answer assumes you are *not using sudo npm i. That would use root's Git config.

Note also you can try an explicit HTTP installation with:

npm i https://github.com/catsaredoomed/invest-openapi-js-sdk.git --save-dev

No Git global setting tweak needed there!

like image 121
VonC Avatar answered Dec 20 '25 01:12

VonC


Seems it was compatibility issue. I updated npm like recommended from 6.14.13 to 7.20

npm install npm@latest -g

And all issues were gone

like image 23
catsaredoomed Avatar answered Dec 20 '25 00:12

catsaredoomed



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!