Powershell script execution from node js fails - node.js

I have a list of Powershell scripts that we've developed for a system administration. These scripts are called/executed from a Node JS application using "child_process" module. Everything works fine on my laptop. After transferring Node JS application to Centos7 server I'm receiving errors like this one:
The term 'Connect-VIServer' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
I've checked Powershell execution policy - everything is set to Unrestricted. I can execute the same scripts from the command line without any error after I ssh to the server as a root user. The only difference I see is that Node JS application is running using a different user.

Found the problem - all modules were installed under /root/.local/share/powershell/Modules directory and nothing was installed under the user's profile that runs Node JS application. Copied all modules under app user directory /home/ndjs/.local/share/powershell/Modules/ and everything work now.

Related

Newman is not recognised as an internal or external command in Jenkins on Windows 10

I'm using newman in Jenkins for executing the postman collection.
A brief background: I have installed node js in C:\Program Files\nodejs and newman was installed using globally so it got installed over here- C:\Users\waniijag\AppData\Roaming\npm\node_modules\newman
About the environment variables:
C:\Users\waniijag\AppData\Roaming\npm got added in the User variables for the user in the Environment variables
Also, I have appended C:\Program Files\nodejs in the Path variable of User variables for user and System variables both.
Now when I'm executing- "newman run Postman collection" OR C:\Users\waniijag\AppData\Roaming\npm\node_modules\newman run postman collection, I'm getting the error as:
'C:\Users\waniijag\AppData\Roaming\npm\node_modules\newman' is not recognized as an internal or external command,
operable program or batch file.
I'm not understanding where I'm going wrong-
Thanks in advance.
add that directory that contains this file, to your environment variable. it will be present in either of:
C:\Users\waniijag\AppData\Roaming\npm\node_modules\.bin
or
C:\Users\waniijag\AppData\Roaming\npm
or directly run it as :
"C:\Users\someuser\AppData\Roaming\npm\newman" run
, imagining that newman.cmd is in npm folder , use this command

confused about writing script for helloworld.js using node-windows in nodejs

I am using node-windows in nodejs to run my nodejs script as a windows service.
now let's suppose that my helloworld.js code is a simple command which creates a folder on desktop. how do I execute this code ??
because my service app starts successfully but it does not do anything at all. it creates no directories on desktop.
please help..
what error am I doing?

failing to install and start windows service with winreg imported

So I'm building a pretty simple service in python3.6. Client want's it to run on windows, so I'm using the win32serviceutil package to make a windows service. I install and package with pyinstaller and so far everything works great.
The issue I'm having is that the path differs between installing, starting and debugging. When installing and debugging, the path is the same as where I run the command from. When starting the service however, the path is C:/windows/system32
The service needs to boot another .exe so it is important having an absolute path to the bundled application. I solved this by writing the path to registry when installing, and reading when starting the service. I do this using the winreg lib. It works great in debug mode, but it seems the service is run under another user when starting the service normally, and it fails to load somehow.
I get Error 1053 : The service did not respond to the start or control request in a timely fashion when running. Importing the winreg lib is fine, but when using it crashes with no error. I'm trying to catch the errors and print but I get nothing on command prompt or the Event Viewer.
Any help appreciated!!

YEOMAN YO ERROR yo it is not recognized as an internal or external command, program or batch file executable.

When installing node.js for the first time and using the YEOMAN library, I found that it did not recognize the library despite installing it correctly.
When executing in console
yo swaggerize
Returns the error "yo it is not recognized as an internal or external command, program or batch file executable"
After several laps the problem is in node.js and in the PATH.
I post the solution in the next post.
The solutiĆ³n for me, it's simple.
In windows-> go to pc properties->advanced configuration-> environment variables
Show Path variable and edit.
C:\Users\youruser\AppData\Roaming\npm;
C:\Program Files\nodejs;
Save restart your console and run the command again
Each and every thing was fine
only problem was path
so I set path in environment variable.
This path I set in environment variabel
C:\Users\user\.npm-packages
where 'user' is my user name, please use your user name.
Then my 'yo', 'bower' command start to executed
Thanks

Running Azure node.js Tools on Ubuntu

I have followed these instructions.
And as far as I can tell I have successfully installed node.js azure tools. No error - nothing to suggest it failed.
However, I cannot, and the documentation says, simple run "azure"...
Maybe there is something I am missing with node.js?
There are a few problems you may be experiencing.
First of all, I would ensure you are running Node.js v0.6.20. You can do this by opening the command prompt and running:
node -v
You should have v0.6.20 echoed back.
If this doesn't work, you may be missing a path variable to Node.js or the NPM cache. Verify the Environment variables exist by running [in the command prompt]:
path
you should see two paths:
%appdata%\npm
[x64 Machine]
%programfiles(x86)%\nodejs\
[x86 Machine]
%programfiles%\nodejs\
If this doesn't work, I would check to ensure that the azure module was loaded into the %appdata%\npm\node_modules directory.
It could be the PATH issue. In my case, the azure program is located at ~/.npm-global/bin.
run "export PATH=$PATH:~/.npm-global/bin". Or just add to bash source file

Resources