npm ERR! code ERR_SOCKET_TIMEOUT on creating new project using ng new appname

Viewed 73836

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.
15 Answers

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

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

Have you tried this :

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

Solve the error for me.

Regards,

It works for Windows:-

npm config delete proxy
npm config delete https-proxy

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.

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

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

if u re on ubuntu disable network proxy in network settings

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

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.

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

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

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

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

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]

Try this one

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

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

Related