Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

Execute NODE JS command



  • Hi,

    I am trying to execute a NODE JS command from buildmaster.

    I tried the following without success:

    • Execute a command line, with a bat file
    • Execute a powershell script
    • Execute a powershell file

    If I execute these commands above, in the server, it works properly. Even for a user without administrative rights.

    I am trying to execute the grunt module, so I am installing the module and run the module. Any idea how to solve this problem?

    The commands I am trying to execute are:

    • npm install grunt-cli -g
    • grunt less

    Thanks,

    Andy

    Product: BuildMaster
    Version: 4.3.7



  • Hi Andy, what specific error message are you getting? Those commands should work, assuming npm and grunt are in the path.

    When using execute command line, note that you have to specify arguments on the arguments field, not in the executable name field.



  • Hi Alana,

    Thank you for your response.

    When executing a command line I did not receive any error message.
    When executing as powershell script I got the following messages:

    Command: npm install -g grunt-cli
    Message: The term 'npm' 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 agai

    Command: grunt less
    Message: The term 'grunt' 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 could execute the first command (npm install -g grunt-cli) from command line. After your message, I set up the command lines as following and it worked perfectly:

    • Executable file: C:\Program Files\nodejs\npm.cmd
    • Arguments: install grunt-cli -g

    After executing the command above, it shows the following:

    C:\Windows\system32\config\systemprofile\AppData\Roaming\npm\grunt -> C:\Windows\system32\config\systemprofile\AppData\Roaming\npm\node_modules\grunt-cli\bin\grunt

    grunt-cli@0.1.13 C:\Windows\system32\config\systemprofile\AppData\Roaming\npm\node_modules\grunt-cliâ -
    nopt@1.0.10 (abbrev@1.0.5)- resolve@0.3.1 - findup-sync@0.1.3 (glob@3.2.11, lodash@2.4.1)

    Now I am facing some issues trying to execute the grunt less command. How can I execute the grunt command?

    Thanks in advance



  • Any help with this?

    Regards



  • Powershell is probably going to be the eaiest way to go, especially as you write more powershell scripts that use Nodejs.

    If you're getting the "npm not found" error during powershell, it sounds like NPM is not on the path. I would do a search for that specific NP not found error message. Heres' what I found, which may or may not be of help?

    http://stackoverflow.com/questions/20992723/npm-is-not-recognized-as-internal-or-external-command-operable-program-or-bat



  • Thanks Alana for your post. That helped me to solve the problem.

    When we install node's modules, it stores the modules into user's appdata folder (eg.: c:\users\joe\appData\Roamind) and add this path into %path% variable.

    Running the command from BuildMaster, it will run as system user, saving the modules into C:\Windows\system32\config\systemprofile\AppData\Roaming\npm\ folder and adds the this path into %path% variable.

    It seems that Windows 64bits has some problems "refreshing" these values for all users/services/process and even if you check the variable, it will display your change, but running process will not get the updated value.

    The solution: Restart the computer. Some people say that is not necessary to restart the computer other people say it is. In my case, restart the computer worked for me.

    After restarted the computer, I could see the path created by grunt install command and I could use the grunt less command with both powershell and bat files.

    Once again, thank you very much Alana.

    Andy



  • Thanks Andy ..server restart did the trick...cheers!!


Log in to reply
 

Inedo Website HomeSupport HomeCode of ConductForums GuideDocumentation