catsaredoomed
catsaredoomed

Reputation: 229

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

Upvotes: 15

Views: 56446

Answers (8)

Code Commander
Code Commander

Reputation: 17310

Wow! as @catsaredoomed suggested, this might just be a bug in specific versions of npm. In my case, it was an issue with npm 8.5.1.

I am running Ubuntu 22.04 LTS (in a docker image), and the default version of Node is v12.22.9 with npm v8.5.1. Using npm install -g npm@latest wouldn't work for me because the absolute latest version of npm doesn't work with Node v12. I was able to determine (as of Aug 3, 2023) the latest version of npm that lists Node v12 as a supported engine is 8.19.4. So I ran:

npm install -g [email protected]

After I logged out of my shell and reconnected. npm is updated, and sure enough, npm install now works without issue.

Upvotes: 0

user1438889
user1438889

Reputation: 1

Thanks, Issue was solved with this command but there was some space after the hyphen .here is the command which I tried and solved the problem

npm i @angular/animations@latest --save

Make sure you need to run the command with the admin

Upvotes: 0

Abhishek Patel
Abhishek Patel

Reputation: 11

Try refer this

npm install # Install only production dependencies ("dependencies", not "devDependencies")
npm install --only=dev # Install only development dependencies ("devDependencies", not "dependencies")

Upvotes: 1

Mahyar8520
Mahyar8520

Reputation: 9

I hope this solution works for you: please try this

npm i @tinkoff/invest-openapi-js-sdk --save

Upvotes: 0

VonC
VonC

Reputation: 1329712

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:

git config --global url."https://github.com/".insteadOf ssh://[email protected]/
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.

Upvotes: 11

awat
awat

Reputation: 195

[email protected]: Permission denied (publickey).
Please follow documentation from Github in order to add ssh access.
You have to add ssh public key on your profile.
https://docs.github.com/en/authentication/troubleshooting-ssh/error-permission-denied-publickey

Verify with ssh -vT [email protected] and after try again to install your npm package.

Upvotes: 0

catsaredoomed
catsaredoomed

Reputation: 229

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

Upvotes: 4

npm i catsaredoomed/invest-openapi-js-sdk --only=dev 

Try this, the --save-dev option is deprecated due to changes in the future versions.

Upvotes: 0

Related Questions