npm / cli

the package manager for JavaScript
https://docs.npmjs.com/cli/
Other
8.42k stars 3.13k forks source link

npm install from private git repository failed #2022

Closed W3mediaPl closed 3 years ago

W3mediaPl commented 3 years ago

NPM 7.x has problem with instaling module from private git repository and gives me ERR_INVALID_URL error. I'm sure that URL is correct, because with npm 6.x everything works fine.

COMMAND: npm install --save git+ssh://git@git.my.private.server:somerepository.git

npm ERR! code ERR_INVALID_URL npm ERR! Invalid URL: git+ssh://git@git.my.private.server:somerepository.git

Environment: OSX 10.15.4

There is debug log:

0 verbose cli [
0 verbose cli   '/usr/local/bin/node',
0 verbose cli   '/usr/local/bin/npm',
0 verbose cli   'install',
0 verbose cli   '--save',
0 verbose cli   'git+ssh://git@############### '
0 verbose cli ]
1 info using npm@7.0.2
2 info using node@v15.0.0
3 timing config:load:defaults Completed in 1ms
4 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 0ms
5 timing config:load:builtin Completed in 1ms
6 timing config:load:cli Completed in 2ms
7 timing config:load:env Completed in 0ms
8 timing config:load:file:/Users/###############/www/_node/###############/.npmrc Completed in 0ms
9 timing config:load:project Completed in 1ms
10 timing config:load:file:/Users/###############/.npmrc Completed in 0ms
11 timing config:load:user Completed in 0ms
12 timing config:load:file:/usr/local/etc/npmrc Completed in 0ms
13 timing config:load:global Completed in 0ms
14 timing config:load:cafile Completed in 1ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:setUserAgent Completed in 0ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 7ms
19 verbose npm-session 01aeaf9109274f1e
20 timing npm:load Completed in 15ms
21 timing arborist:ctor Completed in 0ms
22 timing arborist:ctor Completed in 1ms
23 timing idealTree:init Completed in 24ms
24 timing idealTree Completed in 3277ms
25 timing command:install Completed in 3281ms
26 verbose stack TypeError [ERR_INVALID_URL]: Invalid URL: git+ssh://git@git.############### 
26 verbose stack     at new NodeError (node:internal/errors:258:15)
26 verbose stack     at onParseError (node:internal/url:258:9)
26 verbose stack     at new URL (node:internal/url:334:5)
26 verbose stack     at new URL (node:internal/url:331:22)
26 verbose stack     at GitFetcher.[_addGitSha] (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/git.js:128:28)
26 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/pacote/lib/git.js:228:27
26 verbose stack     at processTicksAndRejections (node:internal/process/task_queues:93:5)
26 verbose stack     at async Arborist.[retrieveSpecName] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:410:18)
26 verbose stack     at async Promise.all (index 0)
26 verbose stack     at async Arborist.[applyUserRequests] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:368:7)
27 verbose cwd /Users/###############/www/_node/############### 
28 verbose Darwin 19.4.0
29 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--save" "git+ssh://git@git.###############"
30 verbose node v15.0.0
31 verbose npm  v7.0.2
32 error code ERR_INVALID_URL
33 error Invalid URL: git+ssh://git@###############
34 verbose exit 1
jimmyhlee94 commented 3 years ago

I had a similar issue... for me I had to replace the : after the domain to a / for it to work.

so instead of git+ssh://git@git.my.private.server:somerepository.git try git+ssh://git@git.my.private.server/somerepository.git

W3mediaPl commented 3 years ago

I tried this way, but still failed.

jmenashe commented 3 years ago

This was working fine 2 months ago, but now it's not.

matschik commented 3 years ago

Got the same problem with git+ssh://git@git.host.com:john/pkg-name#semver:^1.1.4 from Gitlab. Apparently new URL(pkgURL) in NPM 7.0.3 is throwing this error. No problem with Yarn.

davidnorthetal commented 3 years ago

Also getting hit with this, is downgrading the only solution here?

xswei commented 3 years ago

I had a similar issue... for me I had to replace the : after the domain to a / for it to work.

so instead of git+ssh://git@git.my.private.server:somerepository.git try git+ssh://git@git.my.private.server/somerepository.git

Are there relevant documents? thanks

JamesPeck commented 3 years ago

git+ssh://git@privatereponame/orgname/somerepo.git isn't working for us when it used to on v6

greggman commented 3 years ago

Similar problem. npm6 works with a url of git://publicdomain/publicname/reponame.git#tag but npm 7 translates that to git+ssh:... which then fails because other users don't have access to the public repo via ssh

ozkankirik commented 3 years ago

I'm using npm 7.3.0, I hit exactly same error. I've no problems with npm6

it works if protocol git+ssh:// section removed. But this behavior is not expected.

darcyclarke commented 3 years ago

Closing as this seems to be a duplicate of: https://github.com/npm/cli/issues/2054

cmandlbaur commented 3 years ago

@darcyclarke the linked issue seems to address install failures using git+https, whereas this issue is to do with git+ssh.

AndreKR commented 3 years ago

@darcyclarke @cmandlbaur Yeah, the other issue is about authentication with git+https while this one is about ERR_INVALID_URL with git+ssh. Totally different problems.

perryfaro commented 3 years ago

@cmandlbaur @AndreKR I think it is a problemen with node 15.x.x since it works with node 14.x.x and lower using npm version 7.5.4.

Stebeber commented 3 years ago

npm install -g npm@latest solved the issue for me today.

A colleague solved the issue by downgrading npm back to v6.

Pauligrinder commented 3 years ago

npm install -g npm@latest solved the issue for me today.

Hey thanks for mentioning this. This worked for me as well! (Installing an npm package from a vsonline private repo)

kerventkm commented 2 years ago

I have this issue, please any help?

(eeg-models-u_TfKdj2-py3.9) (base) kerven@kerven-Aspire-E1-571G:~/Desktop/Diplom Thesis/eeg-models$ pre-commit run --all-files [INFO] Installing environment for https://github.com/pre-commit/mirrors-prettier. [INFO] Once installed this environment will be reused. [INFO] This may take a few minutes... An unexpected error has occurred: CalledProcessError: command: ('/home/kerven/.cache/pre-commit/repofk4acz7c/node_env-system/bin/node', '/usr/bin/npm', 'install', '-g', '/home/kerven/.cache/pre-commit/repofk4acz7c/placeholder_package-0.0.0.tgz', 'prettier@2.6.2') return code: 1 expected return code: 0 stdout: (none) stderr: npm ERR! code ERR_INVALID_URL npm ERR! Invalid URL

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/kerven/.npm/_logs/2022-05-22T05_59_18_706Z-debug-0.log

Check the log at /home/kerven/.cache/pre-commit/pre-commit.log

0 verbose cli [ 0 verbose cli '/usr/bin/node', 0 verbose cli '/usr/bin/npm', 0 verbose cli 'install', 0 verbose cli '-g', 0 verbose cli '/home/kerven/.cache/pre-commit/repofk4acz7c/placeholder_package-0.0.0.tgz', 0 verbose cli 'prettier@2.6.2' 0 verbose cli ] 1 info using npm@8.5.5 2 info using node@v16.15.0 3 timing npm:load:whichnode Completed in 0ms 4 timing config:load:defaults Completed in 3ms 5 timing config:load:file:/usr/lib/node_modules/npm/npmrc Completed in 1ms 6 timing config:load:builtin Completed in 1ms 7 timing config:load:cli Completed in 3ms 8 timing config:load:env Completed in 1ms 9 timing config:load:project Completed in 13ms 10 timing config:load:file:/home/kerven/.npmrc Completed in 3ms 11 timing config:load:user Completed in 3ms 12 timing config:load:file:/home/kerven/.cache/pre-commit/repofk4acz7c/node_env-system/etc/npmrc Completed in 0ms 13 timing config:load:global Completed in 0ms 14 timing config:load:validate Completed in 1ms 15 timing config:load:credentials Completed in 2ms 16 timing config:load:setEnvs Completed in 1ms 17 timing config:load Completed in 30ms 18 timing npm:load:configload Completed in 30ms 19 timing npm:load:setTitle Completed in 1ms 20 timing config:load:flatten Completed in 4ms 21 timing npm:load:display Completed in 6ms 22 verbose logfile /home/kerven/.npm/_logs/2022-05-22T05_59_18_706Z-debug-0.log 23 timing npm:load:logFile Completed in 8ms 24 timing npm:load:timers Completed in 0ms 25 timing npm:load:configScope Completed in 0ms 26 timing npm:load Completed in 46ms 27 timing arborist:ctor Completed in 2ms 28 silly logfile start cleaning logs, removing 1 files 29 timing idealTree:init Completed in 8ms 30 timing idealTree:userRequests Completed in 61ms 31 silly idealTree buildDeps 32 silly fetch manifest placeholder_package@file:../../placeholder_package-0.0.0.tgz 33 silly fetch manifest prettier@2.6.2 34 silly placeDep ROOT placeholder_package@0.0.0 OK for: want: file:../../placeholder_package-0.0.0.tgz 35 silly placeDep ROOT prettier@ OK for: want: 2.6.2 36 timing idealTree:#root Completed in 31ms 37 timing idealTree:node_modules/placeholder_package Completed in 0ms 38 timing idealTree:node_modules/prettier Completed in 0ms 39 timing idealTree:buildDeps Completed in 33ms 40 timing idealTree:fixDepFlags Completed in 1ms 41 timing idealTree Completed in 104ms 42 timing command:install Completed in 115ms 43 verbose stack TypeError [ERR_INVALID_URL]: Invalid URL 43 verbose stack at new NodeError (node:internal/errors:372:5) 43 verbose stack at URL.onParseError (node:internal/url:553:9) 43 verbose stack at new URL (node:internal/url:629:5) 43 verbose stack at getProxyUri (/usr/lib/node_modules/npm/node_modules/make-fetch-happen/lib/agent.js:157:53) 43 verbose stack at getAgent (/usr/lib/node_modules/npm/node_modules/make-fetch-happen/lib/agent.js:20:17) 43 verbose stack at remoteFetch (/usr/lib/node_modules/npm/node_modules/make-fetch-happen/lib/remote.js:31:17) 43 verbose stack at cacheFetch (/usr/lib/node_modules/npm/node_modules/make-fetch-happen/lib/cache/index.js:16:28) 43 verbose stack at async fetch (/usr/lib/node_modules/npm/node_modules/make-fetch-happen/lib/fetch.js:98:7) 43 verbose stack at async Arborist.[nodeFromEdge] (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1081:19) 43 verbose stack at async Arborist.[buildDepStep] (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:950:11) 44 verbose cwd /home/kerven/.cache/pre-commit/repofk4acz7c 45 verbose Linux 5.13.0-41-generic 46 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "/home/kerven/.cache/pre-commit/repofk4acz7c/placeholder_package-0.0.0.tgz" "prettier@2.6.2" 47 verbose node v16.15.0 48 verbose npm v8.5.5 49 error code ERR_INVALID_URL 50 error Invalid URL 51 verbose exit 1 52 timing npm Completed in 436ms 53 verbose unfinished npm timer reify 1653199159021 54 verbose unfinished npm timer reify:loadTrees 1653199159028 55 verbose code 1 56 error A complete log of this run can be found in: 56 error /home/kerven/.npm/_logs/2022-05-22T05_59_18_706Z-debug-0.log

OliHarris commented 2 years ago

Found this page by searching for string "_nodemodules/make-fetch-happen/lib/agent.js:157:53"

Seeing similar issue with output log:

15:41:05  npm info using npm@8.5.5
15:41:05  npm info using node@v17.8.0

Looks like may have to work on way to downgrade npm while keeping node 17..?

Govindghosh commented 1 year ago

PS E:\Learn\React js\learn\sstart> npx create-react-app my-utilite

Creating a new React app in E:\Learn\React js\learn\sstart\my-utilite.

Installing packages. This might take a couple of minutes. Installing react, react-dom, and react-scripts with cra-template...

npm ERR! code ERR_INVALID_URL npm ERR! Invalid URL

npm ERR! A complete log of this run can be found in: C:\Users\ok\AppData\Local\npm-cache_logs\2023-09-29T10_40_36_131Z-debug-0.log

Aborting installation. npm install --no-audit --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.

Deleting generated file... package.json Deleting my-utilite/ from E:\Learn\React js\learn\sstart Done.

can anybody help me..?