Skip to content

request to http://registry.npmjs.org/@angular-devkit%2fbuild-angular failed, reason: connect ECONNREFUSED 127.0.0.1:4200 #139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sohini1302 opened this issue Sep 9, 2020 · 12 comments

Comments

@sohini1302
Copy link

Hi,
I am facing this issue on downloading node and then installing npm:
'CALL "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" prefix -g' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ECONNREFUSED
npm ERR! errno ECONNREFUSED
npm ERR! FetchError: request to http://registry.npmjs.org/@angular-devkit%2fbuild-angular failed, reason: connect ECONNREFUSED 127.0.0.1:4200
npm ERR! at ClientRequest. (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14)
npm ERR! at ClientRequest.emit (events.js:315:20)
npm ERR! at Socket.socketErrorListener (_http_client.js:426:9)
npm ERR! at Socket.emit (events.js:315:20)
npm ERR! at emitErrorNT (internal/streams/destroy.js:92:8)
npm ERR! at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
npm ERR! at processTicksAndRejections (internal/process/task_queues.js:84:21)
npm ERR! FetchError: request to http://registry.npmjs.org/@angular-devkit%2fbuild-angular failed, reason: connect ECONNREFUSED 127.0.0.1:4200
npm ERR! at ClientRequest. (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14)
npm ERR! at ClientRequest.emit (events.js:315:20)
npm ERR! at Socket.socketErrorListener (_http_client.js:426:9)
npm ERR! at Socket.emit (events.js:315:20)
npm ERR! at emitErrorNT (internal/streams/destroy.js:92:8)
npm ERR! at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
npm ERR! at processTicksAndRejections (internal/process/task_queues.js:84:21) {
npm ERR! type: 'system',
npm ERR! errno: 'ECONNREFUSED',
npm ERR! code: 'ECONNREFUSED',
npm ERR! parent: 'APM-Start'
npm ERR! }

@DeborahK
Copy link
Owner

DeborahK commented Sep 9, 2020

Can you detail the exact steps and commands you used?

The URL in your message doesn't seem correct. Downloading/installing npm should not be accessing anything from Angular or the angular-devkit.

Check out the course here: https://app.pluralsight.com/course-player?clipId=9ae1778f-7d2c-47d9-8dfd-2bd279316dbc
At time code 2:05 to walk through the steps for installing node/npm.

@sohini1302
Copy link
Author

I have installed node--> checked the version for node and npm.--> changed directory in cmd prompt to the apm start folder --> typed npm install and came up with above error.

@sohini1302
Copy link
Author

I have installed node--> checked the version for node and npm.--> changed directory in cmd prompt to the apm start folder --> typed npm install and came up with above error.

Looks like I got this error now:
C:\Users\sroy3\Documents\Angular-GettingStarted-master\APM-Start>npm install
'CALL "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" prefix -g' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ECONNREFUSED
npm ERR! errno ECONNREFUSED
npm ERR! FetchError: request to http://registry.npmjs.org/@angular-devkit%2fbuild-angular failed, reason: connect ECONNREFUSED 127.0.0.1:4200
npm ERR! at ClientRequest. (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14)
npm ERR! at ClientRequest.emit (events.js:315:20)
npm ERR! at Socket.socketErrorListener (_http_client.js:426:9)
npm ERR! at Socket.emit (events.js:315:20)
npm ERR! at emitErrorNT (internal/streams/destroy.js:92:8)
npm ERR! at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
npm ERR! at processTicksAndRejections (internal/process/task_queues.js:84:21)
npm ERR! FetchError: request to http://registry.npmjs.org/@angular-devkit%2fbuild-angular failed, reason: connect ECONNREFUSED 127.0.0.1:4200
npm ERR! at ClientRequest. (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14)
npm ERR! at ClientRequest.emit (events.js:315:20)
npm ERR! at Socket.socketErrorListener (_http_client.js:426:9)
npm ERR! at Socket.emit (events.js:315:20)
npm ERR! at emitErrorNT (internal/streams/destroy.js:92:8)
npm ERR! at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
npm ERR! at processTicksAndRejections (internal/process/task_queues.js:84:21) {
npm ERR! type: 'system',
npm ERR! errno: 'ECONNREFUSED',
npm ERR! code: 'ECONNREFUSED',
npm ERR! parent: 'APM-Start'
npm ERR! }
npm ERR!
npm ERR! If you are behind a proxy, please make sure that the
npm ERR! 'proxy' config is set properly. See: 'npm help config'

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\sroy3\AppData\Roaming\npm-cache_logs\2020-09-09T16_40_33_002Z-debug.log

@DeborahK
Copy link
Owner

DeborahK commented Sep 9, 2020

OK. So this isn't a problem with downloading npm and installing node. This is a problem with the install of the application's packages.

Looking up the ECONNFEFUSED message, it is a "connection refused by server". This is most likely caused by a firewall, proxy, or other security issue. Are you on a machine that is "locked down" or otherwise restricted access to the internet?

If so, you need to ensure npm is set up properly in the proxy config.

You could try the steps suggested by your error message:

npm ERR! 'proxy' config is set properly. See: 'npm help config'

Or check out the docs here: https://docs.npmjs.com/cli/config

Or this article: https://jjasonclark.com/how-to-setup-node-behind-web-proxy/

If none of that works for you, you can instead work through the course using stackblitz, which is an online editor that allows you to build Web applications without having to install anything. You can find the instructions for using stackblitz with this course here: https://github.com/DeborahK/Angular-GettingStarted#stackblitz

Let me know if something here helps!

@sohini1302
Copy link
Author

Hi Deborah,

I am working in my corporate office laptop and I tried this, which did not help me:
C:\Users\sroy3\Documents\Angular-GettingStarted-master\APM-Start>npm config set proxy http://office******.com:8080
'CALL "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" prefix -g' is not recognized as an internal or external command,
operable program or batch file.

@DeborahK
Copy link
Owner

DeborahK commented Sep 9, 2020

Did you have any luck with any of the other resources I listed?

Is there a help desk or IT support person that can help?

Otherwise, I'd suggest going with my stackblitz suggestion.

@sohini1302
Copy link
Author

HI Deborah,
I tried changing the http proxy from null to my office proxy server and still no good luck with that. I learnt about this from one of the resources you shared. IT support person could help me with the server name.

Also, I would like to mention that earlier I was unable to install other npm packages, but now I am able to do except for these dependiencies.

The error that I got after this is:
C:\Users\sroy3\Documents\Angular-GettingStarted-master\APM-Start>npm install
'CALL "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" prefix -g' is not recognized as an internal or external command,
operable program or batch file.
npm WARN deprecated [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated [email protected]: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated

[email protected] postinstall C:\Users\sroy3\Documents\Angular-GettingStarted-master\APM-Start\node_modules\core-js
node -e "try{require('./postinstall')}catch(e){}"

npm WARN notsup Unsupported engine for [email protected]: wanted: {"node":"<8.10.0"} (current: {"node":"12.18.3","npm":"6.14.6"})
npm WARN notsup Not compatible with your version of node/npm: [email protected]
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\watchpack-chokidar2\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\webpack-dev-server\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! syscall spawn C:\Windows\System32
npm ERR! file C:\Windows\System32
npm ERR! path C:\Windows\System32
npm ERR! errno ENOENT
npm ERR! [email protected] postinstall: node -e "try{require('./postinstall')}catch(e){}"
npm ERR! spawn C:\Windows\System32 ENOENT
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.

@DeborahK
Copy link
Owner

DeborahK commented Sep 9, 2020

It looks like the packages installed. Most of those are just warnings.

What version of node did you install? I'd highly recommend the LTS (Long Term Support) version which is currently 12.18.3. Not the "Current" version which is 14.10.0. In looking at the warning messages, it seems that some of the libraries are not compatible with node 14 at this time.

The ending message is saying a post install script didn't work. Are you trying to run this on docker?

I'm not sure what the postinstall script all needs to do, but you could try running the app (with npm start) and see if it works without successful completion of the postinstall script.

@sohini1302
Copy link
Author

I am using v12.18.3 for node and no I am not running this on docker. On npm start command, this is the issue:
C:\Users\sroy3\Documents\Angular-GettingStarted-master\APM-Start>node -v
v12.18.3

C:\Users\sroy3\Documents\Angular-GettingStarted-master\APM-Start>npm start
'CALL "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" prefix -g' is not recognized as an internal or external command,
operable program or batch file.

[email protected] start C:\Users\sroy3\Documents\Angular-GettingStarted-master\APM-Start
ng serve -o

npm ERR! code ELIFECYCLE
npm ERR! syscall spawn C:\Windows\System32
npm ERR! file C:\Windows\System32
npm ERR! path C:\Windows\System32
npm ERR! errno ENOENT
npm ERR! [email protected] start: ng serve -o
npm ERR! spawn C:\Windows\System32 ENOENT
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

@DeborahK
Copy link
Owner

DeborahK commented Sep 9, 2020

At this point, I see three options:

  1. You could try deleting it all. Uninstalling node. And starting over. I'm not sure that will get your any further?

  2. You could try installing the Angular CLI and see if you get any further with that. In the course we don't install it until later, but you could try it now.

  3. You could use stackblitz as mentioned above so you don't need to install anything.

I've not had anyone run into so many install issues since Angular moved to webpack several years ago. So I don't have a lot of tips to share. :-(

@sohini1302
Copy link
Author

I have actually tried point 1 and 2.
If I use stackblitz, can I make http call to some backend server endpoints?
I see that you have used a json file, but i was wondering if I could use a real backend server endpoint to fetch some table data.

@DeborahK
Copy link
Owner

DeborahK commented Sep 9, 2020

So does the install of the Angular CLI generate the same error message?

Yes, you can use stackblitz to access a "real" backend server endpoint. We just don't do it in the course because then we'd need to set one up (or depend on an existing one.)

I have an example here: https://stackblitz.com/edit/angular-posts-user-todos-forkjoin-deborahk

It uses a public "todo" API on a real backend server somewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants