# Moment on Nodered function Node

**URL:** <https://discourse.nodered.org/t/moment-on-nodered-function-node/83718>\
**Category:** General\
**Created:** [14 December 2023 15:12 UTC](https://discourse.nodered.org/t/moment-on-nodered-function-node/83718 "2023-12-14T15:12:50Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Riccaleu](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/riccaleu/32/83807_2.png) [@Riccaleu](https://discourse.nodered.org/u/Riccaleu)\
**Post date:** [14 December 2023 15:12 UTC](https://discourse.nodered.org/t/moment-on-nodered-function-node/83718/1 "2023-12-14T15:12:50Z")

</div>

Hi evryone

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

```auto
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

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [14 December 2023 15:42 UTC](https://discourse.nodered.org/t/moment-on-nodered-function-node/83718/2 "2023-12-14T15:42:32Z")

</div>

Are you behind a proxy?

---

<div class="post-metadata">

**Author:** ![Riccaleu](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/riccaleu/32/83807_2.png) [@Riccaleu](https://discourse.nodered.org/u/Riccaleu)\
**Post date:** [14 December 2023 16:33 UTC](https://discourse.nodered.org/t/moment-on-nodered-function-node/83718/3 "2023-12-14T16:33:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [14 December 2023 16:36 UTC](https://discourse.nodered.org/t/moment-on-nodered-function-node/83718/4 "2023-12-14T16:36:25Z")

</div>

> [@Riccaleu](#):
>
> noderd fails

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

---

<div class="post-metadata">

**Author:** ![Riccaleu](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/riccaleu/32/83807_2.png) [@Riccaleu](https://discourse.nodered.org/u/Riccaleu)\
**Post date:** [14 December 2023 16:42 UTC](https://discourse.nodered.org/t/moment-on-nodered-function-node/83718/5 "2023-12-14T16:42:29Z")

</div>

> [@Colin](#):
>
> node-red-stop

none of them works, mybe i do it wrong

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [14 December 2023 16:44 UTC](https://discourse.nodered.org/t/moment-on-nodered-function-node/83718/6 "2023-12-14T16:44:23Z")

</div>

In that case presumably you did not install node-red using the recommended script [Running on Raspberry Pi : Node-RED](https://nodered.org/docs/getting-started/raspberrypi)

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.

---

<div class="post-metadata">

**Author:** ![Riccaleu](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/riccaleu/32/83807_2.png) [@Riccaleu](https://discourse.nodered.org/u/Riccaleu)\
**Post date:** [14 December 2023 16:51 UTC](https://discourse.nodered.org/t/moment-on-nodered-function-node/83718/7 "2023-12-14T16:51:59Z")

</div>

> [@Colin](#):
>
> `node-red-stop`  
> `node-red-start`

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

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [14 December 2023 16:53 UTC](https://discourse.nodered.org/t/moment-on-nodered-function-node/83718/8 "2023-12-14T16:53:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [14 December 2023 16:59 UTC](https://discourse.nodered.org/t/moment-on-nodered-function-node/83718/9 "2023-12-14T16:59:05Z")

</div>

> [@Riccaleu](#):
>
> > [@Colin](#):
> >
> > `node-red-stop`  
> > `node-red-start`
> 
> Sorry colin did not explain myself proprerly, im working on windows

`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.

> [@Riccaleu](#):
>
> ```auto
> npm ERR! code ETIMEDOUT
> npm ERR! syscall connect
> npm ERR! errno ETIMEDOUT
> 
> ```

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

> [@Riccaleu](#):
>
> `network request to (https/Proxy registrY)/moment failed`

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.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [14 December 2023 17:11 UTC](https://discourse.nodered.org/t/moment-on-nodered-function-node/83718/10 "2023-12-14T17:11:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Riccaleu](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/riccaleu/32/83807_2.png) [@Riccaleu](https://discourse.nodered.org/u/Riccaleu)\
**Post date:** [14 December 2023 17:14 UTC](https://discourse.nodered.org/t/moment-on-nodered-function-node/83718/11 "2023-12-14T17:14:05Z")

</div>

> [@Steve-Mcl](#):
>
> And this looks very wrong.

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/](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]

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [14 December 2023 17:59 UTC](https://discourse.nodered.org/t/moment-on-nodered-function-node/83718/12 "2023-12-14T17:59:54Z")

</div>

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"`

---

<div class="post-metadata">

**Author:** ![Riccaleu](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/riccaleu/32/83807_2.png) [@Riccaleu](https://discourse.nodered.org/u/Riccaleu)\
**Post date:** [15 December 2023 08:15 UTC](https://discourse.nodered.org/t/moment-on-nodered-function-node/83718/13 "2023-12-15T08:15:42Z")

</div>

> [@Steve-Mcl](#):
>
> And you state you computer that runs Node-RED _does_ have internet access (or at least access to the NPM registry)?

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

> [@Steve-Mcl](#):
>
> 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?

i did not set ny HTTPS proxy on node-red

> [@Steve-Mcl](#):
>
> can you `ping npmjs.com`

yes

> [@Steve-Mcl](#):
>
> Can you `cURL https://registry.npmjs.org/moment/-/moment-2.29.4.tgz --output C:\temp\moment.tgz`

yes but here the resutl

```auto
`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

```

`

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [15 December 2023 08:28 UTC](https://discourse.nodered.org/t/moment-on-nodered-function-node/83718/14 "2023-12-15T08:28:54Z")

</div>

I'm confused.

Are your problems now fixed?

Or do you still need help?

---

<div class="post-metadata">

**Author:** ![Riccaleu](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/riccaleu/32/83807_2.png) [@Riccaleu](https://discourse.nodered.org/u/Riccaleu)\
**Post date:** [15 December 2023 08:50 UTC](https://discourse.nodered.org/t/moment-on-nodered-function-node/83718/15 "2023-12-15T08:50:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [15 December 2023 08:57 UTC](https://discourse.nodered.org/t/moment-on-nodered-function-node/83718/16 "2023-12-15T08:57:47Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![Riccaleu](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/riccaleu/32/83807_2.png) [@Riccaleu](https://discourse.nodered.org/u/Riccaleu)\
**Post date:** [15 December 2023 09:39 UTC](https://discourse.nodered.org/t/moment-on-nodered-function-node/83718/17 "2023-12-15T09:39:39Z")

</div>

> [@Steve-Mcl](#):
>
> Which account runs node-red?

ADMIN

> [@Steve-Mcl](#):
>
> Does that account NEED a proxy setting

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

> [@Steve-Mcl](#):
>
> Does that account have access to NPM

yes

> [@Steve-Mcl](#):
>
> Have you set the necessary ENV VARs for that account

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

> [@Steve-Mcl](#):
>
> What proxy settings are set in in NPM config (both local account and global)

how can i check this config?

---

<div class="post-metadata">

**Author:** ![Riccaleu](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/riccaleu/32/83807_2.png) [@Riccaleu](https://discourse.nodered.org/u/Riccaleu)\
**Post date:** [15 December 2023 09:49 UTC](https://discourse.nodered.org/t/moment-on-nodered-function-node/83718/18 "2023-12-15T09:49:23Z")

</div>

i found this on .npmrc

```auto
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

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [15 December 2023 10:31 UTC](https://discourse.nodered.org/t/moment-on-nodered-function-node/83718/19 "2023-12-15T10:31:20Z")

</div>

> [@Riccaleu](#):
>
> > [@Steve-Mcl](#):
> >
> > Does that account NEED a proxy setting
> 
> no any proxy for the account it sims is a problem of Npm/node-red

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.

> [@Riccaleu](#):
>
> found this on .npmrc
> 
> ```auto
> 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

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:

```bash
    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"

```

---

<div class="post-metadata">

**Author:** ![Riccaleu](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/riccaleu/32/83807_2.png) [@Riccaleu](https://discourse.nodered.org/u/Riccaleu)\
**Post date:** [15 December 2023 10:40 UTC](https://discourse.nodered.org/t/moment-on-nodered-function-node/83718/20 "2023-12-15T10:40:55Z")

</div>

> [@Steve-Mcl](#):
>
> If you have an `.npmrc` file then that might be why `npm` cannot install - try deleting it (or temporarily renaming it to something else)

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

[Next page](https://discourse.nodered.org/t/moment-on-nodered-function-node/83718.md?page=2)
