Skip to content

Website & Server Help

Unlimited Webspace Help

Menu
  • Home
  • Apps
  • Website
    • Sending email from a WordPress website hosted on an IONOS server
    • How to increase Upload Max Filesize
    • How to reset a WordPress password
    • 22 Ways To Speed-Up A Plesk Website
  • Server
    • Linux or Plesk Server Error 500
    • Windows Server: File cannot be loaded. The file is not digitally signed.
    • Adding or modifying IP addresses on a Linux server
    • Installing Remote Desktop on Debian 12
    • Installing Remote Desktop on Ubuntu 22.04
    • How To Install a Let’s Encrypt SSL in Apache on Debian/Ubuntu
  • Favs
    • How to Connect to a Server
    • The Ultimate Guide to Setting Up a Proper Plesk Email Server With IONOS
    • The Ultimate IONOS Migration Guide
    • Help! My Plesk Websites Are Down!
    • Running tests for a slow server or dropped packets
    • Checking File System and Hard Drive Health
Menu

Modifying the icon and file properties of a Node.JS app compiled with PKG

Posted on January 19, 2025January 21, 2025 by admin

If you’ve built an application using Node.JS, and compiled it to a Windows binary with PKG, you will have noticed that the file description, copyright, and icon match those of the Node.JS runtime. Updating the file properties with Resource Hacker sometimes works, however, updating the icon may corrupt the application, so that it will no longer run.

Follow along and we will show you how to update the properties of a Windows .exe that has been built as Node.JS code compiled with PKG.

Set the PKG_CACHE_PATH environment variable

export PKG_CACHE_PATH=./cacheFolder

Download the Node.js Binary

pkg .

Rename the modified binary (cacheFolder/v3.4/fetched-v18.5.0-win-x64) to replace fetched with built. For example: built–v18.5.0-win-x64 so that pkg recognizes it as custom-built.

Install rcedit

npm install rcedit

Create a modbinary.js:

const rcedit = require("rcedit");
const path = require("path");
async function modifyBinary() {
  const binaryPath = path.join(
    __dirname,
  "cacheFolder/v3.4/built-v18.5.0-win-x64"
  );
await rcedit(binaryPath, {
    icon: "C:\\icon.ico",
    "version-string": {
      FileDescription: "My cool app",
      ProductName: "myApp",
      LegalCopyright: "Copyright My Company. All Rights Reserved.",
      OriginalFilename: "myApp.exe",
      CompanyName: "My Company",
      InternalName: "My Company",
      FileVersion: "1.0.0",
      ProductVersion: "1.0.0",
    },
    "file-version": "1.0.0",
    "product-version": "1.0.0",
  });
}
modifyBinary()
  .then(() => console.log("Binary modified successfully!"))
  .catch((err) => console.error("Error modifying binary:", err));

Be sure to replace the binaryPath with the correct file location (cacheFolder/v3.4/fetched-v18.5.0-win-x64, but will be different versions depending on Node.JS). Notice the additional escape backslash when specifying the icon file location on Windows. Update this location to the correct path of your icon file.

Run the script

node ./binmod.js

Build Your Executable Using pkg

pkg --target node18-win-x64 --output yourAppName .

Special Offer

The internet's fastest, cheapest, unlimited bandwidth VPS

VPS
1core | 1GB RAM | 10GB NVMe
Unlimited Bandwidth | 1Gbps
$2/month - risk free