Inno Setup Node.js Compiler Wrapper
The `innosetup-compiler` package provides a Node.js wrapper for the Inno Setup Compiler (`ISCC.exe`), enabling programmatic or command-line compilation of `.iss` scripts. Currently at version 6.4.1, it primarily facilitates integrating Inno Setup compilation into Node.js-based build workflows, including CLI and Grunt tasks. Its key differentiator is cross-platform compatibility, allowing compilation on Linux and macOS environments provided Wine is installed, translating calls to the Windows-native `ISCC.exe`. This package acts as an orchestrator, executing the official Inno Setup compiler, rather than reimplementing the compiler itself, ensuring compatibility with the latest Inno Setup features. While not on a strict release cadence, it is actively maintained to support current Node.js and Inno Setup versions.
Common errors
-
err:macdrv:process_attach Failed to start Cocoa app main loop
cause An outdated or unstable version of Wine on macOS is attempting to run the Inno Setup compiler, leading to an application launch failure.fixUpdate Wine to the latest development version using Homebrew: `brew update && brew install wine --devel`. -
Error: Command failed: C:\Program Files (x86)\Inno Setup 6\ISCC.exe "path\to\my\script.iss" [...] /O="output\directory" [...] Error on line X: Unknown parameter 'O'.
cause Inno Setup compiler options are being passed incorrectly, specifically with a leading slash `/O=` instead of without for this wrapper's API.fixEnsure all Inno Setup compiler options passed via the Node.js API or CLI are provided without the leading slash (e.g., `{ O: 'output/directory' }` for Node.js, or `--O=output/directory` for CLI) as the wrapper adds it automatically. Review the official Inno Setup Command Line Compiler Execution documentation for valid parameters.
Warnings
- gotcha Running `innosetup-compiler` on non-Windows operating systems (Linux, macOS) requires a working installation of Wine to execute the Windows-native `ISCC.exe` compiler.
- gotcha When the `gui` option is set to `true`, `innosetup-compiler` will launch `Compil32.exe` (the Inno Setup GUI compiler), and all other programmatic options passed to the function will be ignored. The user must manually interact with the GUI.
- gotcha When defining `signtoolcommand` or other paths in JavaScript strings, especially for Windows paths, backslashes must be escaped with an additional backslash (e.g., `C:\\path\\to\\file.pfx`).
- deprecated The package's `engines.node` specifies `>=0.8.0`. While it may still function on modern Node.js versions, this outdated engine declaration might indicate a lack of testing or specific optimizations for newer Node.js features (e.g., native ESM).
Install
-
npm install innosetup -
yarn add innosetup -
pnpm add innosetup
Imports
- compileInnoSetup
import compileInnoSetup from 'innosetup-compiler';
const compileInnoSetup = require('innosetup-compiler'); - CLI
innosetup-compiler myscript.iss --gui
- GruntTask
import { innosetup_compiler } from 'innosetup-compiler';grunt.loadNpmTasks('innosetup-compiler');
Quickstart
const compileInno = require('innosetup-compiler');
const path = require('path');
const scriptPath = path.join(__dirname, 'my-installer.iss');
// Example .iss content for my-installer.iss (save this file next to your script)
// [Setup]
// AppName=My Awesome App
// AppVersion=1.0
// DefaultDirName={autopf}\My Awesome App
// FileName=MyAppSetup.exe
// OutputBaseFilename=MyAppInstaller
// compression=lzma2
// SolidCompression=yes
// PrivilegesRequired=admin
// SourceDir=.\
// [Files]
// Source: "MyApp.exe"; DestDir: "{app}"
compileInno(scriptPath, {
gui: false,
verbose: true,
O: path.join(__dirname, 'output'), // Specifies output directory
signtoolname: 'signtool',
signtoolcommand: '"C:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.19041.0\\x64\\signtool.exe" sign /f "C:\\absolute\\path\\to\\mycertificate.pfx" /t http://timestamp.digicert.com /p "MY_PASSWORD" $f'
}, function(error) {
if (error) {
console.error('Inno Setup compilation failed:', error);
process.exit(1);
} else {
console.log('Inno Setup compilation successful!');
console.log(`Installer saved to: ${path.join(__dirname, 'output', 'MyAppInstaller.exe')}`);
}
});