56

Can somebody help me on this? i am getting following error:

Angular & Node version Installed

Angular CLI: 12.0.1
Node: 14.16.0
Package Manager: npm 7.11.2
OS: win32 x64
    D:\Learning\Angular>ng new working
    ? Would you like to add Angular routing? No
    ? Which stylesheet format would you like to use? CSS
    CREATE working/angular.json (3045 bytes)
    CREATE working/package.json (1069 bytes)
    CREATE working/README.md (997 bytes)
    CREATE working/tsconfig.json (783 bytes)
    CREATE working/.editorconfig (274 bytes)
    CREATE working/.gitignore (604 bytes)
    CREATE working/.browserslistrc (703 bytes)
    CREATE working/karma.conf.js (1424 bytes)
    CREATE working/tsconfig.app.json (287 bytes)
    CREATE working/tsconfig.spec.json (333 bytes)
    CREATE working/src/favicon.ico (948 bytes)
    CREATE working/src/index.html (293 bytes)
    CREATE working/src/main.ts (372 bytes)
    CREATE working/src/polyfills.ts (2820 bytes)
    CREATE working/src/styles.css (80 bytes)
    CREATE working/src/test.ts (743 bytes)
    CREATE working/src/assets/.gitkeep (0 bytes)
    CREATE working/src/environments/environment.prod.ts (51 bytes)
    CREATE working/src/environments/environment.ts (658 bytes)
    CREATE working/src/app/app.module.ts (314 bytes)
    CREATE working/src/app/app.component.html (23777 bytes)
    CREATE working/src/app/app.component.spec.ts (943 bytes)
    CREATE working/src/app/app.component.ts (211 bytes)
    CREATE working/src/app/app.component.css (0 bytes)
    / Installing packages (npm)...npm WARN deprecated urix@0.1.0: Please see     https://github.com/lydell/urix#deprecated
    npm WARN deprecated har-validator@5.1.5: this library is no longer supported
    npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
    npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
    npm WARN deprecated request@2.88.2: request has been deprecated, see         https://github.com/request/request/issues/3142
    npm ERR! code ERR_SOCKET_TIMEOUT
    npm ERR! errno ERR_SOCKET_TIMEOUT
    npm ERR! request to https://registry.npmjs.org/@angular/cli/-/cli-12.0.1.tgz failed, reason: Socket timeout

    npm ERR! A complete log of this run can be found in:
    npm ERR!     C:\Users\username\AppData\Local\npm-cache\_logs\2021-05-23T07_57_24_639Z-debug.log
    × Package install failed, see above.
    The Schematic workflow failed. See above.
HDJEMAI
  • 9,436
  • 46
  • 67
  • 93
Mehran Khan
  • 960
  • 1
  • 6
  • 16
  • timeout issues may occur due to connectivity issue. Make sure you've an active internet connection with a decent speed – Sagar V May 23 '21 at 08:28

25 Answers25

91

Your command cannot succeed, because npm fails to fetch some module due to internet connection problems. You can try using different internet connection or increasing npm fetch timeouts.

I just had this issue and it helped changing timeouts:

npm config set fetch-retry-mintimeout 20000
npm config set fetch-retry-maxtimeout 120000

You can find default values running:

npm config ls -l
rlf89
  • 1,336
  • 1
  • 11
  • 17
30

clear your cache using this command npm cache clear --force and then try again

ram
  • 437
  • 2
  • 12
27

Have you tried this :

- npm config rm proxy
- npm config rm https-proxy

Solve the error for me.

Regards,

12

It works for Windows:-

npm config delete proxy
npm config delete https-proxy
Syscall
  • 19,327
  • 10
  • 37
  • 52
Riyadh Ahmed
  • 121
  • 1
  • 6
8

The registry URL is pointing to 'https'. There are chances you might be using a proxy that is blocking secure connections

Run npm config set registry="http://registry.npmjs.org/" and then try creating the app.

The command npm get registry shows the current URL it is pointing to.

ram
  • 437
  • 2
  • 12
6

Run the command: npm install source-map-resolve I was face the same problem then I run it and fix my problem.

  • 1
    If possible, could you add a little more info as to what this would do and how it would help address the problem? Thanks! – tklives Jan 18 '22 at 15:03
  • 1
    While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value. – CascadiaJS Jan 18 '22 at 22:53
  • 1
    That package is deprecated ([source](https://www.npmjs.com/package/source-map-resolve)). – Jeremy Caney Jan 19 '22 at 01:26
  • It worked for me, I am working on openedx and this is an issue I faced when building custom mfes, would love to know how this helped fix the issue – Seif Hafri Mar 07 '23 at 13:43
3

according to my experience better to use,

npm config set fetch-retry-mintimeout 200000
npm config set fetch-retry-maxtimeout 1200000

insted of "npm config set fetch-retry-mintimeout 20000" & "npm config set fetch-retry-maxtimeout 120000". Because this didn't work for me.

2

I tried everything but this work for me: What I did is that I uninstall the node 16 and degrade it to node 14. Then in my command line I typed this code npm set timeout=100000

  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/30642713) – CodeChanger Dec 24 '21 at 07:04
2

1st step:
npm install webpack webpack-cli --global
2nd step:
npm install rxjs
3rd step:
npm install webpack webpack-cli --global
4th step:
npm install -g https://tls-test.npmjs.com/tls-test-1.0.0.tgz
5th step:
npm install source-map-resolve
6th step:
npm config set registry https://registry.npmjs.org/

[1-3] perform for react
if you are facing this problem for angular perform [1-6]

Limon
  • 21
  • 2
2

Try this one

npm config set registry http://registry.npmjs.org/

set NPM config like this use http: instead of https:

1

If you are using windows, ensure you try running using administrator command prompt

  • This worked for me well, I tried to clean cache, tried to delete proxy as well, but only this worked. Thank you – ashrth Dec 30 '22 at 07:13
1

if u re on ubuntu disable network proxy in network settings

1

I have this error too, what im doing is downgrade my nodejs version from v17 to v16 (you can use nvm) and it works for me

Zulfikar Ahmad
  • 407
  • 1
  • 7
  • 18
1

Pls close and reopen your command shell after you just installed node js library. That's worked well for me.

Alex Kim
  • 11
  • 2
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 14 '22 at 15:52
1

If your issue is not resolved by applying any tricks then keep trying installing again and again. It is just a matter of time. Your installation process will be completed after a few attempts.

1

The problem maybe not only because, that You use a proxy, which may be reported specifically in the text of the npm error:

npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'

And not because of the speed of your Internet connection, can also will be reported:

npm ERR! network This is a problem related to network connectivity

Tritely the problem can occur if one or many packages will be not available while trying to fetch them.

Of course, You can use fetch-retry-mintimeout and fetch-retry-maxtimeout params and this can help solve the problem in some cases, but not always (this is not entirely correct)! Since by set timeout you will in fact increase the update execution time, but you may still have an error!

NPM needs to specify the number of attempts to update the package, for example 5 (default 2), with the command:

npm config set fetch-retries 5

Tested on npm 9.4.0, Angular 15.2! It option is working!

0
  • npm config rm proxy
  • npm config rm https-proxy

then, reinstall react-app. Works for me on Macbook Pro (Intel).

0

I had the same error. The solution was to change the definition of the timeout.

It worked for me like a charm ✨

For changing the timeout, Run these two commands:

npm config set fetch-retry-mintimeout 20000

npm config set fetch-retry-maxtimeout 120000

I hope this helps.

Efrat Ifergan
  • 184
  • 1
  • 5
0

I had the same error but I just opened up vscode on admin and it worked like a charm

sevub
  • 1
  • 2
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 19 '22 at 07:36
0

This commands worked for me:

 npm config set registry http://registry.npmjs.org/
 npm install -d
Erik P_yan
  • 608
  • 5
  • 6
0

Quick fix for error:0308010C:digital envelope routines::unsupported Version 18 and above of NODE for NUXT

The quick fix by adding this command in terminal

Mac

export NODE_OPTIONS=--openssl-legacy-provider

Windows

set NODE_OPTIONS=--openssl-legacy-provider
Ruchir
  • 1,018
  • 7
  • 17
0

just with one line you can fix it ,it's worked with me :

config set fetch-retry-maxtimeout 120000000

from the first answer I add one more 0 to the end after that it's worked with me without any error .

0

Switch to nodejs lts version 18.16.0. In 20.2.0 it is not working

mbmeet
  • 1
  • 1
0

For me it worked when I wrote this on my terminal (my system is Linux Mint 21.1):

npm install --no-audit --save --save-exact --loglevel error react react-dom react-scripts cra-template
ahuemmer
  • 1,653
  • 9
  • 22
  • 29
Mikias
  • 1
0

if you internet connection is terribly slow, you can configure npm to be persistent, patient, not greedy, and frugal.

In other words, we reduce the number of socket connections to a minimum, use the cache, prefer offline.

For this

  1. Update npm
npm install -g npm
  1. Config (per-user config file ~/.npmrc)
fetch-retry-maxtimeout=30000
fetch-retry-mintimeout=3000
fetch-timeout=6000
fetch-retry-factor=10
fetch-retries=15
strict-ssl=false
ca=null
maxsockets=1
; offline=true // deprecated alias of next line
cache-min=9999
; next line use as flag at install command
prefer-offline=true
  1. Install with command
npm i --prefer-offline

So, it can work on 64Kbite/sec connection; long but reliable!

DraKoan
  • 21
  • 4