Chris Lang
Chris Lang

Reputation: 384

'bower' is not recognized, want to have Jenkins install grunt, bower

I am getting the issue 'bower' is not recognized while running my Jenkins project as I have seen many other people get. However, I know I can get it to work by including the hardcoded path

C:\Users\clang\AppData\Roaming\npm 

in my path environment variable. This is not the way I want to do it though.

My goal is to have this Jenkins configuration be able to download, install, and run these commands locally and be able to do so without hardcoding a path as I want it to run on other computers that would have different users hence different paths. This is my current batch script that I am running.

set PATH=%PATH%; %WORKSPACE%\.bin;
call npm install
call npm install bower
call npm install grunt-cli
call bower install
call grunt build

when bower and grunt are installed by this, the bower.cmd and grunt.cmd are located in this directory

C:\Program Files (x86)\Jenkins\workspace\ClearWork\.bin

The command I am running at the top does in fact evaluate to and include the directory where these command files are located but for some reason I am still getting the error saying that bower and grunt are not recognized.

Just to make sure it wasn't an issue with the Jenkins %Workspace% environment variable I even hard coded the location which gave the same result.

Upvotes: 0

Views: 1424

Answers (1)

CaptEmulation
CaptEmulation

Reputation: 4586

Option 1

call node_modules/.bin/bower install
call node_modules/.bin/grunt build

Option 2

Add these as scripts to the package.json:

(inside package.json)

  "scripts": {
    "bower:install": "bower install",
    "grunt:build": "grunt build"
  }

Now you should be able to call:

call npm run bower:install
call npm run grunt:build

Because npm automatically adds node_modules/.bin to the path

Upvotes: 1

Related Questions