Moment on Nodered function Node

Hi evryone

i have a problem if i try to install moment module in fuction node , here the log:

npm ERR! code ETIMEDOUT
npm ERR! syscall connect
npm ERR! errno ETIMEDOUT
npm ERR! network request to (https/Proxy registrY)/moment failed, reason: connect ETIMEDOUT 52.179.84.101:4873
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network 
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'

i alredy installed globally troutgth npm install

any ideas?

Thank You

Are you behind a proxy?

yes, i mange to by pass it thanks npm install, but noderd fails

In what way? Post the output you get when you run
node-red-stop
node-red-start
Copy/paste please not screenshot

none of them works, mybe i do it wrong

In that case presumably you did not install node-red using the recommended script Running on Raspberry Pi : Node-RED

In that case stop node-red and start it again in a command window using whatever method you normally use.
I presume, since you have not said, that you are not using Docker or Home Assistant.

Sorry colin did not explain myself proprerly, im working on windows, in a VPN of my client, for another client i manged it with no problem

You need to open a command window on the pi and run the commands.

node-red-stop node-red-start are not windows things (these are service start/stop commands setup by the PI installer script) - forget about these for now.

Clearly the Node-RED server (backend part - not the front end browser you are using to access the node-red) cannot access the internet.

And this looks very wrong.


On windows, if you have not redirected output of node-red to a file, then there is no way to get the log. You can however simply start node-red in a command terminal under the correct account that _normally runs it (usually started by typing node-red into a command terminal) to see the output of node-red.

Oh, I have mixed two threads up, I thought this was on a pi.

I believe that @Riccaleu has got past the npm problem but now has an error stating node red.

i put this to hide the registry, by the way i know how to run it, here below the full log hiding private url/name in bold

14 Dec 18:08:13 - [info] Node-RED version: v3.0.2
14 Dec 18:08:13 - [info] Node.js version: v16.14.2
14 Dec 18:08:13 - [info] Windows_NT 10.0.20348 x64 LE
14 Dec 18:08:13 - [warn] Use of editorTheme.palette.editable is DEPRECATED. Use externalModules.palette.allowInstall instead
14 Dec 18:08:15 - [info] Loading palette nodes
14 Dec 18:08:19 - [info] Settings file : C:\Users\riccardo.leuci.node-red\settings.js
14 Dec 18:08:19 - [info] Context store : 'default' [module=memory]
14 Dec 18:08:19 - [info] User directory : \Users\riccardo.leuci.node-red
14 Dec 18:08:19 - [warn] Projects disabled : editorTheme.projects.enabled=false
14 Dec 18:08:19 - [info] Flows file : \Users\ user i.node-red\flows.json
14 Dec 18:08:19 - [info] Server now running at http://127.0.0.1:1880/
14 Dec 18:08:19 - [warn]


Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.

You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------

14 Dec 18:08:19 - [info] Installing module: moment, version: latest
14 Dec 18:10:36 - [error] Installation of module moment failed:
14 Dec 18:10:52 - [error] ------------------------------------------
14 Dec 18:10:52 - [error] npm ERR! code ETIMEDOUT
npm ERR! syscall connect
npm ERR! errno ETIMEDOUT
npm ERR! network request to https: hide/ moment failed, reason: connect ETIMEDOUT 52.179.84.101:4873
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
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'

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\ user \AppData\Local\npm-cache_logs\2023-12-14T17_08_21_730Z-debug-0.log

14 Dec 18:10:52 - [error] ------------------------------------------
14 Dec 18:10:52 - [info] Failed to load external modules required by this flow:
14 Dec 18:10:52 - [info] - moment [unexpected_error]

So again, as you can see, Node-RED is not connecting to the internet.

And you state you computer that runs Node-RED does have internet access (or at least access to the NPM registry)?

Does the internet access require a proxy setting and if so, have you set HTTP_PROXY (and associated env vars) on the Node-RED server?

As a test, on the Node-RED server, can you ping npmjs.com? Can you cURL https://registry.npmjs.org/moment/-/moment-2.29.4.tgz --output C:\temp\moment.tgz (or in PS Invoke-WebRequest -Uri "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz" -OutFile "C:\temp\moment.tgz"

Yes, i mange to install moment module thank to tha registry

i did not set ny HTTPS proxy on node-red

yes

yes but here the resutl

`C:\Windows\system32>cURL https://registry.npmjs.org/moment/-/moment-2.29.4.tgz --output C:\temp\moment.tgzcURL https://registry.npmjs.org/moment/-/moment-2.29.4.tgz --output C:\temp\moment.tgz^Z
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0Warning: Failed to create the file C:\temp\moment.tgzcURL: No such file or
Warning: directory
  2  681k    2 17350    0     0  51716      0  0:00:13 --:--:--  0:00:13 51946
curl: (23) Failure writing output to destination
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0Warning: Failed to create the file C:\temp\moment.tgz: No such file or
Warning: directory
  2  681k    2 14612    0     0  97538      0  0:00:07 --:--:--  0:00:07 98067
curl: (23) Failure writing output to destination

C:\Windows\system32>cURL https://registry.npmjs.org/moment/-/moment-2.29.4.tgz --output C:\temp\moment.tgz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0Warning: Failed to create the file C:\temp\moment.tgz: No such file or
Warning: directory
  2  681k    2 15981    0     0  72547      0  0:00:09 --:--:--  0:00:09 72972
curl: (23) Failure writing output to destination

`

I'm confused.

Are your problems now fixed?

Or do you still need help?

I'm sorry to not explain me well , but no resoloution yet.
When run node-red from CMD i still have that problem(even as admin ), the execution tries to install moment but fails as before

What is not clear:

  1. Which account runs node-red?
  2. Does that account NEED a proxy setting
  3. Does that account have access to NPM
  4. Have you set the necessary ENV VARs for that account
  5. What proxy settings are set in in NPM config (both local account and global)

ADMIN

no any proxy for the account it sims is a problem of Npm/node-red

yes

did not set anything, how to check the ENV vars?

how can i check this config?

i found this on .npmrc

egistry=https: **url** :4873/
strict-ssl=false

it literrally don't know why is there it should not compare. is related to a my company )(a sort of hub ov node palette

That response does not make sense to me.

Is there a proxy involved in the communication from the Windows machine to the internet?

  • If YES, then you need to set Env Vars accordingly.

  • If NO, ignore.

If you have an .npmrc file then that might be why npm cannot install - try deleting it (or temporarily renaming it to something else).


If you do need proxy settings (ignore if not)

In previous times, this is how I have set proxy details on windows to permit Node-RED (NPM) install via a proxy:

    SET PROXY=http://my-proxy-ip:8000/
    setx HTTP_PROXY http://%PROXY%/ /M 
    setx HTTPS_PROXY http://%PROXY%/ /M 
    setx NO_PROXY "127.0.0.1, localhost, _others_non_proxy_entries_" /M 

    start cmd /c "npm config set proxy http://%PROXY%/"
    start cmd /c "npm config set https-proxy http://%PROXY%/"
    start cmd /c "npm config set strict-ssl false"

did it sorry to waste your time but i'm new with node, networks and so on. Can you briefly explain what is Npmrc file
thanks for anything.

Riccardo