# Alternate-node-red-installer and pkg

**URL:** <https://discourse.nodered.org/t/alternate-node-red-installer-and-pkg/74402>\
**Category:** General\
**Tags:** alternate-node-red-installer\
**Created:** [30 January 2023 11:11 UTC](https://discourse.nodered.org/t/alternate-node-red-installer-and-pkg/74402 "2023-01-30T11:11:07Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![norchenne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/norchenne/32/74999_2.png) [@norchenne](https://discourse.nodered.org/u/norchenne)\
**Post date:** [30 January 2023 11:11 UTC](https://discourse.nodered.org/t/alternate-node-red-installer-and-pkg/74402/1 "2023-01-30T11:11:07Z")

</div>

Hello,  
I have installed node-red using alternate-node-red-installer and created my flows that i want to package using pkg,  
I have seen a topic that was closed talking about it but couldn't figure out what to do  
Node-RED version: v3.0.2  
Node.js version: v16.15.0  
pkg version : 5.8.0

Here is what i added in my package.json  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/d/0d4227086e2f897e6510f1100f2236deb554b78c.png)

I don't know if it's the correct settings because I have all these warnings and errors appearing when running .exe file after the packaging

 ![exec node-red](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/0/d04b0321adaab00a5ca54ddf8d9c3b0138a750e0.png)

can you help please ?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [30 January 2023 11:26 UTC](https://discourse.nodered.org/t/alternate-node-red-installer-and-pkg/74402/2 "2023-01-30T11:26:21Z")

</div>

The other thread that is referenced is here:

> [@Can I package whole nodered project using pkg node?](https://discourse.nodered.org/t/can-i-package-whole-nodered-project-using-pkg-node/56271/6):
>
> Hi @TotallyInformation I actually managed it using pkg. by adding this package.json [image] Then run "pkg ." It has 3 outputs for different OS: then I can use the .exe file on my command prompt, I just need to put --userDir arguments. [image] And it works just like "npm start" on your alternate-installer. The advantage of doing this is you just have to copy the node-red-master-win.exe to any other computer along with the "data" folder. and you can run node-red on any computer …

Not sure that ever got resolved and without further input, the thread auto-closed.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [30 January 2023 11:34 UTC](https://discourse.nodered.org/t/alternate-node-red-installer-and-pkg/74402/3 "2023-01-30T11:34:30Z")

</div>

Well, the first thing to fix are the warnings. They all say the same thing and it points to the `httpNodeRoot` property in your settings.js - it is set to `false` which turns off the ability to use `http-in` nodes. Set it to an empty string instead.

The errors look like they come from you trying to use node.js modules in function nodes. The packager won't have picked those up and so your executable can't do anything when it comes to them. Move the require statements to the globals section of the settings.js file and make sure they are listed as dependencies in the userDir package.json file so that the packager includes them. Then adjust your function nodes to remove the references in setup and change the code to get a reference to the module from the global context.

e.g.

```auto
const fs = global.get('fs')

```

---

<div class="post-metadata">

**Author:** ![norchenne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/norchenne/32/74999_2.png) [@norchenne](https://discourse.nodered.org/u/norchenne)\
**Post date:** [30 January 2023 14:28 UTC](https://discourse.nodered.org/t/alternate-node-red-installer-and-pkg/74402/4 "2023-01-30T14:28:47Z")

</div>

Thank you so much for your help, it resolved all of the errors and warnings;  
And everything works fine on my machine, but when I wanted to share the .exe file along with the UserDir file, it didn't want to start and access refused was written on terminal of another machine  
Do you know why perhaps?

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [30 January 2023 14:36 UTC](https://discourse.nodered.org/t/alternate-node-red-installer-and-pkg/74402/5 "2023-01-30T14:36:40Z")

</div>

Can you paste the exact error from terminal?  
and the command line to run the executable

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [30 January 2023 14:38 UTC](https://discourse.nodered.org/t/alternate-node-red-installer-and-pkg/74402/6 "2023-01-30T14:38:04Z")

</div>

I use `pkg` to compile an image for various platforms (not NR related)

---

<div class="post-metadata">

**Author:** ![norchenne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/norchenne/32/74999_2.png) [@norchenne](https://discourse.nodered.org/u/norchenne)\
**Post date:** [30 January 2023 15:08 UTC](https://discourse.nodered.org/t/alternate-node-red-installer-and-pkg/74402/7 "2023-01-30T15:08:02Z")

</div>

the command line to run the executable is : `node-red-master.exe --userDir ./data`  
error : access denied

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [30 January 2023 15:16 UTC](https://discourse.nodered.org/t/alternate-node-red-installer-and-pkg/74402/8 "2023-01-30T15:16:11Z")

</div>

And you're working in the directory that `node-red-master.exe` resides?  
if so - is UAC/Defender/Firewall getting in the way? - Given its an executable from 'another location'?

Not sure what else to check, given this is not a "normal" way to run Node RED 😅

---

<div class="post-metadata">

**Author:** ![Henjoe](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henjoe/32/52335_2.png) [@Henjoe](https://discourse.nodered.org/u/Henjoe)\
**Post date:** [30 January 2023 15:18 UTC](https://discourse.nodered.org/t/alternate-node-red-installer-and-pkg/74402/9 "2023-01-30T15:18:39Z")

</div>

Have you run thr .pkg ?  
I don't see you run the pkg module.  
You need install the pkg module first.

---

<div class="post-metadata">

**Author:** ![norchenne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/norchenne/32/74999_2.png) [@norchenne](https://discourse.nodered.org/u/norchenne)\
**Post date:** [30 January 2023 15:20 UTC](https://discourse.nodered.org/t/alternate-node-red-installer-and-pkg/74402/10 "2023-01-30T15:20:37Z")

</div>

Yeah 😅 i know it's not the usual way to run it  
but i want to distribute my app to clients that's why this is required  
anyway , yes i am working in the same directory as `node-red-master.exe`  
maybe it's something to do with defender  
(honestly I don't know)

---

<div class="post-metadata">

**Author:** ![norchenne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/norchenne/32/74999_2.png) [@norchenne](https://discourse.nodered.org/u/norchenne)\
**Post date:** [30 January 2023 15:21 UTC](https://discourse.nodered.org/t/alternate-node-red-installer-and-pkg/74402/11 "2023-01-30T15:21:19Z")

</div>

yes the module is installed that's how I generated the executable file

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [30 January 2023 15:22 UTC](https://discourse.nodered.org/t/alternate-node-red-installer-and-pkg/74402/12 "2023-01-30T15:22:14Z")

</div>

Check if the executable is blocked in properties?

---

<div class="post-metadata">

**Author:** ![norchenne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/norchenne/32/74999_2.png) [@norchenne](https://discourse.nodered.org/u/norchenne)\
**Post date:** [1 February 2023 09:50 UTC](https://discourse.nodered.org/t/alternate-node-red-installer-and-pkg/74402/13 "2023-02-01T09:50:57Z")

</div>

Sorry for the delayed response, everything works well now, the access denied error just disappeared after I restarted the machine.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [15 February 2023 09:51 UTC](https://discourse.nodered.org/t/alternate-node-red-installer-and-pkg/74402/14 "2023-02-15T09:51:37Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
