cli icon indicating copy to clipboard operation
cli copied to clipboard

[BUG] git+ssh does not work with version 8.16

Open VeXell opened this issue 1 year ago • 13 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

This issue exists in the latest npm version

  • [X] I am using the latest npm

Current Behavior

Hello

Using the latest version of npm 8.16 and latest 14.20 version of node.js.

I have few dependencies which i install from local git server.
When i remove node_modules folder and want to install packages again with command npm i i get error:

2833 verbose stack TypeError [ERR_INVALID_URL]: Invalid URL: git+ssh://git@***:frontend/utils.git#6d45447e0c5eb6cd2e3edf05a8c5a9bb81950c79
2833 verbose stack     at new NodeError (internal/errors.js:322:7)
2833 verbose stack     at onParseError (internal/url.js:270:9)
2833 verbose stack     at new URL (internal/url.js:346:5)
2833 verbose stack     at Arborist.[registryResolved] (***/.nvm/versions/node/v14.20.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:721:25)
2833 verbose stack     at Arborist.[extractOrLink] (***/.nvm/versions/node/v14.20.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:641:72)
2833 verbose stack     at ***/.nvm/versions/node/v14.20.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:607:35

But with npm 8.15.1 is works fine.

Expected Behavior

Packages with git+ssh path should be installed

Environment

  • npm: 8.16.0
  • Node.js: v14.20.0
  • OS Name: MacOS 11.6.8
  • System Model Name: Macbook Pro

VeXell avatar Aug 08 '22 19:08 VeXell

The same npm: 8.16.0 Node.js: v18.7.0 OS Name: Windows 11

Delagen avatar Aug 10 '22 06:08 Delagen

Same here npm: 8.17.0 Node.js: v16.16.0 OS Name: Windows 11

bnpoirier avatar Aug 11 '22 13:08 bnpoirier

Any news? 8.18.0 version already released

Delagen avatar Aug 22 '22 12:08 Delagen

Same here. All our pipelines fail, I had to fix all NPM versions to 8.15.

lazybobcat avatar Aug 25 '22 13:08 lazybobcat

i even get now errors like npm exec not working with packages anymore when one includes a git dependencie is in the packages it does fail silently

frank-dspeed avatar Aug 30 '22 07:08 frank-dspeed

throw error ERR_INVALID_URL in this line https://github.com/npm/cli/blob/fa014a5567566c764942600441a5e01c3e2f229b/workspaces/arborist/lib/arborist/reify.js#L721

node URL not support parse git+ssh://

bigbossx avatar Sep 09 '22 10:09 bigbossx

@VisonM I think that they need to use

const {parse}=require("node:url");

instead of global version of URL, because of Node.JS global URL is strict whatwg version, but Chromium is some patched version

Delagen avatar Sep 09 '22 10:09 Delagen

@VisonM I think that they need to use

const {parse}=require("node:url");

instead of global version of URL, because of Node.JS global URL is strict whatwg version, but Chromium is some patched version

You are right. you can try send a fix pr. I'm not completely familiar with how npmcli works.

bigbossx avatar Sep 09 '22 12:09 bigbossx

@VisonM created )

Delagen avatar Sep 09 '22 13:09 Delagen

This is missing steps to reproduce. What entry in your package.json causes this?

wraithgar avatar Sep 14 '22 22:09 wraithgar

This is missing steps to reproduce. What entry in your package.json causes this?

@wraithgar

For example in my case access to local git server. You can try any lib source with git+ssh

"devDependencies": {
       ...
        "etools": "git+ssh://git@git.***:frontend/dev-build-tools.git",
       ...
    }

VeXell avatar Sep 14 '22 22:09 VeXell

Any package comming from github or gitlab. For us that's a private gitlab repository, I can't link it here.

lazybobcat avatar Sep 14 '22 22:09 lazybobcat

https://github.com/npm/cli/pull/5487#issuecomment-1247371710

@lazybobcat Just replace colon with slash as workaround

"devDependencies": {
       ...
        "etools": "git+ssh://git@git.***/frontend/dev-build-tools.git",
       ...
    }

Delagen avatar Sep 14 '22 22:09 Delagen

I have the same problem and @Delagen workaround fixed it !

stadja avatar Sep 30 '22 13:09 stadja

Still same problem exists! It's critical to use local git repositories! please write a test for this condition, is it possible to fix and commit it as soon as possible

ozkankirik avatar Oct 03 '22 05:10 ozkankirik

Same issue with npm cli bundled with nodejs 16.18.0

breisig avatar Oct 13 '22 16:10 breisig

This is a serious issue that needs to get fixed ASAP!

breisig avatar Oct 17 '22 23:10 breisig

Is there a solution for gitlab url for https?like this: git+https://xxx.com/xxx/common-react-components.git#3.7.3

1765659645 avatar Dec 07 '22 07:12 1765659645

Is there a solution for gitlab url for https?like this: git+https://xxx.com/xxx/common-react-components.git#3.7.3

I had the same problem and @Delagen workaround fixed it !

stadja avatar Dec 07 '22 08:12 stadja

有没有针对https的gitlab url的解决方案?像这样:git+ https://xxx.com/xxx/common-react-components.git#3.7.3

我遇到了同样的问题@Delagen 解决方法修复了它!

Did you change https to ssh and that solved it?

1765659645 avatar Dec 07 '22 08:12 1765659645

Sorry, I didn't read your problem well. What is your problem exactly ? Https doesn't work ?

stadja avatar Dec 07 '22 08:12 stadja

I'm https now, how to fix it without modifying it to ssh way?

1765659645 avatar Dec 07 '22 09:12 1765659645