0

under devDependencies i have placed the post install as below and wanted to update webdriver-manager

"devDependencies": {
"@angular/cli": "1.6.8",
"@angular/compiler-cli": "^5.2.0",
"@angular/language-service": "^5.2.0",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-junit-reporter": "^1.2.0",
"karma-mocha-reporter": "^2.2.3",
"karma-phantomjs-launcher": "^1.0.4",
"ngx-cookie-service": "^1.0.10",
"node-sass": "^4.13.0",
"protractor": "^5.4.2",
"retire": "^1.6.0",
"ts-node": "~4.1.0",
"tslint": "~5.9.1", 
"typescript": "~2.5.3",
"postinstall": "cd ./node_modules/protractor && npm i webdriver-manager@latest && cd ../.. && ./node_modules/.bin/webdriver-manager update"
}

when i try to run npm i it throws below error:

npm ERR! Could not install from "cd node_modules\protractor && npm i webdriver-manager@latest" as it 
does not contain a package.json file.

Can anyone please suggest what is the solution for this?

user1498069
  • 124
  • 2
  • 14

1 Answers1

3

I'm not aware of the devDependancy section allowing any scripts so from what I understand you will need to put this under the scripts section instead.

Additionally there are a couple of things you should be aware of:

When Protractor is installed it will automatically install webdriver-manager and place the binaries for both protractor itself and webdriver-manager in node_modules/.bin. So it is not necessary to change directories to node_modules/protractor to access webdriver-manager.

Also, when you are writing scripts in the package.json it is not necessary to specify that it is a local package (by saying node_modules/...) as the scripts always check the local packages first.

Therefore I believe your conf should look like the below and should work the way you intend

  "scripts": {
    "postinstall": "webdriver-manager update"
  },
  ...
  ...
  "devDependencies": {
    "@angular/cli": "1.6.8",
    "@angular/compiler-cli": "^5.2.0",
    "@angular/language-service": "^5.2.0",
    "@types/jasmine": "~2.8.3",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "^4.0.1",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "^3.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-junit-reporter": "^1.2.0",
    "karma-mocha-reporter": "^2.2.3",
    "karma-phantomjs-launcher": "^1.0.4",
    "ngx-cookie-service": "^1.0.10",
    "node-sass": "^4.13.0",
    "protractor": "^5.4.2",
    "retire": "^1.6.0",
    "ts-node": "~4.1.0",
    "tslint": "~5.9.1",
    "typescript": "~2.5.3",
  }
DublinDev
  • 2,318
  • 2
  • 8
  • 31
  • just writing "postinstall": "webdriver-manager update" will not work it still throws the error session not created: This version of ChromeDriver only supports Chrome version 76 using "postinstall": "cd ./node_modules/protractor && npm i webdriver-manager@latest" will work – user1498069 Dec 17 '19 at 06:08
  • Can you please help on this now i get the error I/update - chromedriver: unzipping chromedriver_79.0.3945.36.zip I/launcher - Running 1 instances of WebDriver /direct - Using ChromeDriver directly... E/launcher - session not created: This version of ChromeDriver only supports Chrome version 79 (Driver info: chromedriver=79.0.3945.16 it now started to throw that driver is not compatible with chrome browser – user1498069 Dec 18 '19 at 11:14
  • Use `npm run postinstall` to execute the post install script so that the approach I posted should still work. The error indicates the version of chrome you have installed is different to the chromedriver version installed. Can you verify your chrome version, it may need to be updated – DublinDev Dec 19 '19 at 16:25