13

I have a package.json file like this

{
  "name": "E2E",
  "version": "1.0.0",
  "description": "AngularJS E2E testing",
  "main": "conf.js",
  "scripts": {
    "postinstall": "node_modules/protractor/bin/webdriver-manager update",
    "test": "echo \"Error: no test specified\" && exit 1"
  },  
  "license": "ISC",
  "devDependencies": {
    "protractor": "^2.2.0"
  }
}

when running command npm install after protractor is installed its throwing error

node_modules/protractor/bin/webdriver-manager update
'node_modules' is not recognized as an internal or external command, operable program or batch file
coure2011
  • 40,286
  • 83
  • 216
  • 349
  • 1
    Can you tell us what command are you trying to run after installing the dependencies? – giri-sh Sep 15 '15 at 11:55
  • on command prompt I type node_modules/protractor/bin/webdriver-manager update – coure2011 Sep 15 '15 at 12:01
  • You have to go to the folder before executing the command `webdriver-manager update`. Updated answer based on that. – giri-sh Sep 15 '15 at 12:19
  • Do you run this command on Windows? If so, [check this out](http://stackoverflow.com/questions/18413157/how-do-i-get-rid-of-error-is-not-recognized-as-an-internal-or-external-comm) – Michael Radionov Sep 15 '15 at 12:35

3 Answers3

20

Ok found the fix, I need to run it as node command like this

"postinstall": "node node_modules/protractor/bin/webdriver-manager update",
coure2011
  • 40,286
  • 83
  • 216
  • 349
1

Try prepending the path to executable with a dot followed by a slash:

 ./node_modules/protractor/bin/webdriver-manager update
Pavlo
  • 43,301
  • 14
  • 77
  • 113
0

The problem is that you need to be in the folder where that command is installed before you call it. Assuming you are using Windows, this can be solved by running a simple batch file:

@echo off
call npm install -g protractor
call npm install
cd C:/Users/%USERNAME%/AppData/Roaming/npm/node_modules/protractor/selenium/
call webdriver-manage update

You should be able to run a batch file from anywhere. In fact, the entire Protractor testing process can be automated with a batch file. You just need to add Grunt, load-grunt-tasks, grunt-protractor-runner, jasime, and protractor-jasmine2-html-reporter to your package.json:

{
    "name": "yourproject",
    "version": "0.0.1",
    "dependencies": { },
    "devDependencies": {
        "grunt": "~0.4.1",
        "load-grunt-tasks": "~1.0.0",
        "grunt-protractor-runner": "~2.1.0",
        "jasmine": "~2.3",
        "protractor-jasmine2-html-reporter": "~0.0.5"
    },
  "engines": {
      "node": ">=0.12.0"
  }
}

After you configure Protractor and writing some tests, you can then call the whole process with one simple batch file:

@echo off
cd %CD%
@echo running tests
call grunt
@echo Opening test results in browser
start "" %CD%\tests\reports\index.html
MBielski
  • 6,628
  • 3
  • 32
  • 43