Service not found after install service node-windows

335 Views Asked by At

My install service script as below:

install_windows_service.js

require("dotenv").config();
var Service = require("node-windows").Service;

// Create a new service object
var svc = new Service({
  name: "STUtility",
  description: "The web app with STUtility tools.",
  script: process.env.WORKING_DIRECTORY + "index.js",
  nodeOptions: ["--harmony", "--max_old_space_size=4096"],
  workingDirectory: process.env.WORKING_DIRECTORY,
  allowServiceLogon: true,
  env: {
    name: "NODE_ENV",
    value: "production",
  },
});

// Listen for the "install" event, which indicates the
// process is available as a service.

svc.on("install", function () {
  svc.start();
  console.log("install complete.");
  console.log("The service exists: ", svc.exists);
});

// Just in case this file is run twice.

svc.on("alreadyinstalled", function () {
  console.log("This service is already installed.");
});

// Listen for the "start" event and let us know when the

// process has actually started working.
svc.on("start", function () {
  console.log(svc.name + " started!.");
});

svc.on("error", function () {
  console.log("Something went wrong.");
});

svc.on("invalidinstallation ", function () {
  console.log(" This service is detected but missing require files");
});

svc.install();

In terminal I run command:

node .\install_windows_service.js

Terminal show:

install complete. The service exists: true

But I cannot find out this service on Windows Services.

0

There are 0 best solutions below