-1

I would like to know if we can write/pass the npm-start command as a JS script.

Requirement: Create a JS script that can execute the command npm-start.

OS: Microsoft Windows


My requirement is to convert it to a Windows service. However, for the below code under script I cannot directly pass npm-start.

var Service = require('node-windows').Service;

// Create a new service object
var svc = new Service({
  name:'npm-start',
  description: 'start npm',
  script: 'pass npm-start command as a script.js'
});

svc.on('install', function(){
  svc.start();
});

svc.install();
Arnav Thorat
  • 3,078
  • 3
  • 8
  • 33
  • Please add your code that you have tried so that we can correct you, instead of giving you code. **This question may lead to opinions.** – Arnav Thorat Oct 12 '22 at 02:39
  • hi, below is the code. my requirement is to covert it to a windows service. however for below code under script i cannot directly pass 'npm-start' `var Service = require('node-windows').Service; // Create a new service object var svc = new Service({ name:'npm-start', description: 'start npm', script: 'js script to pass npm-start.js' }); svc.on('install',function(){ svc.start(); }); svc.install();` – user20211149 Oct 12 '22 at 02:43
  • Did *Joe105598055*'s question help you? – Arnav Thorat Oct 12 '22 at 03:16
  • @ArnavThorat im taking a look at that still. But im still open for suggestions and help on this. This is something new for me. – user20211149 Oct 12 '22 at 03:33
  • Okay, cool! I'm big on coding and the Windows operating system, but not sure how to solve your question. I'm still working it out though! – Arnav Thorat Oct 12 '22 at 03:51

1 Answers1

-1

Try it. If you want to create command line interface.

https://www.npmjs.com/package/commander

JoeH
  • 368
  • 1
  • 3
  • 9