Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm error - Cannot find module './selenium-webdriver/lib/input'

After I updated my Angular project's version from 5 to 7, I was getting a lot of vulnerabilities, to fix it - I ran all the commands that was suggested in the "npm audit" and all the vulnerabilities was fixed.

But now when I run:

ng serve

I get this error:

ERROR in node_modules/protractor/built/ptor.d.ts(33,17): error TS2307: Cannot find module './selenium-webdriver/lib/input'.

Edit

If I get in to the errors sources I can see the problem line:

// node_modules/protractor/built/ptor.d.ts
 Key: import("./selenium-webdriver/lib/input").IKey;

and if I change the line to:

 Key: import("../../selenium-webdriver/lib/input").IKey;

it's fix the error.

I guess it's a versions issue, but now remains to find out what the correct versions.

This is my package.json file:

{
"name": "test",
 "version": "1.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular-devkit/core": "7.3.6",
"@angular/animations": "7.2.11",
"@angular/common": "7.2.11",
"@angular/compiler": "7.2.11",
"@angular/core": "7.2.11",
"@angular/forms": "7.2.11",
"@angular/http": "7.2.11",
"@angular/platform-browser": "7.2.11",
"@angular/platform-browser-dynamic": "7.2.11",
"@angular/router": "7.2.11",    
"core-js": "^2.4.1",
"rxjs": "^6.4.0",
"selenium-webdriver": "^4.0.0-alpha.1",
"tslib": "^1.9.0",
"zone.js": "^0.8.29"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.13.7",
"@angular/cli": "7.3.6",
"@angular/compiler-cli": "7.2.11",
"@angular/language-service": "7.2.11",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "^4.0.1",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "^6.0.0",
"ts-node": "~3.2.0",
"tslint": "~5.7.0",
"typescript": "3.2.4"
 },
"description": "This project was generated with [Angular CLI] 
(https://github.com/angular/angular-cli) version 1.6.3.",
"main": "/",
"repository": {
"type": "git",
"url": "/"
 },
"keywords": [
"/"
],
"author": "/"
}

Any ideas why?

like image 627
levi Avatar asked Mar 28 '19 08:03

levi


2 Answers

To resolve this issue I had to run this command:

npm install protractor@latest --save

like image 171
jt123 Avatar answered Nov 15 '22 13:11

jt123


This error comes when you import from 'protactor' rather than '@angular/platform-browser' in your test cases.

like image 2
ireshika piyumalie Avatar answered Nov 15 '22 14:11

ireshika piyumalie