coreybutler / node-windows

Windows support for Node.JS scripts (daemons, eventlog, UAC, etc).
Other
2.79k stars 358 forks source link

how to run angular-http-server through the script #246

Closed mounesh143 closed 4 years ago

mounesh143 commented 4 years ago

i was trying below code

var Service = require('node-windows').Service; //const {exec} = require('child_process'); // Create a new service object var svc = new Service({ name:'JackFruit Angular Dashboard', description: 'The nodejs.org example web server.',

script: 'angular-http-server --config configs/angular-http-server.config.js', 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(); });

// 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!\nVisit http://localhost:8181/ to see it in action.'); });

// Install the script as a service. svc.install();

// "scripts": { // "start": "angular-http-server --config configs/angular-http-server.config.js",

// },

---------------- getting below error---------------- fs.js:114 throw err; ^

Error: ENOENT: no such file or directory, mkdir 'C:\Users\badigm\Desktop\windows\windows-dashboard\windows-dashboard\angular-http-server --config configs\daemon' at Object.mkdirSync (fs.js:757:3) at C:\Users\badigm\Desktop\windows\windows-dashboard\windows-dashboard\node_modules\node-windows\lib\daemon.js:514:16 at suppressedCallback (fs.js:199:5) at FSReqWrap.args [as oncomplete] (fs.js:140:20)

Is there any option to run npm command in script ...?

coreybutler commented 4 years ago

The script should be a filepath, not a command. angular-http-server is its own CLI application. These types of apps are designed to be used standalone. In other words, it won't work with node-windows.