6

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?

halfer
  • 19,824
  • 17
  • 99
  • 186
levi
  • 1,077
  • 2
  • 11
  • 24

8 Answers8

4

To resolve this issue I had to run this command:

npm install protractor@latest --save

jt123
  • 41
  • 4
2

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

ireshika piyumalie
  • 2,226
  • 22
  • 22
0

It looks like the problem is with the package with @types:

https://github.com/angular/protractor/issues/5192

Maybe try use previous version for example: @types/selenium-webdriver@2.53.33

Eutrepe
  • 866
  • 1
  • 9
  • 9
  • i will need to remove before the "selenium-webdriver"? – levi Mar 28 '19 at 08:22
  • probably not but if this not work you can install previus version for "selenium-webdriver" too – Eutrepe Mar 28 '19 at 08:24
  • it's seems like the error actually fixed. but now another errors come. like ERROR in node_modules/protractor/built/driverProviders/local.d.ts(1,10): error TS2305: Module '"selenium-webdriver/remote"' has no exported member 'SeleniumServer' – levi Mar 28 '19 at 08:38
  • Try maybe with other version: https://www.npmjs.com/package/@types/selenium-webdriver?activeTab=versions – Eutrepe Mar 28 '19 at 08:53
  • i try another versions but it's steel not work. please see my edit. – levi Mar 28 '19 at 09:14
0

Can you try these two commands in terminal to ensure that all the packages are installed:

npm i selenium-webdriver --save and npm i

which is also same as

npm install selenium-webdriver --save and npm install

Seba Cherian
  • 1,755
  • 6
  • 18
  • did you try it by removing node_modules folder and package-lock.json file? – Seba Cherian Mar 28 '19 at 09:16
  • It's for fresh installing. Some times these old folders may cause issues, shich I have encountered few times. So I suggested doing so. fyi 'i' in 'npm i' stands for 'npm install' – Seba Cherian Mar 28 '19 at 09:50
0
  1. Backup your code including node_modules folder
  2. Remove node_modules folder and package-lock.json file
  3. Run the following command in root folder of the application

    npm i
    
    ng serve
    
piet.t
  • 11,718
  • 21
  • 43
  • 52
Vinodh Ram
  • 709
  • 1
  • 9
  • 22
  • Why would you want to back up your code now instead of always backing up your code with some form of Git service like GitHub? – Edric Mar 28 '19 at 08:22
  • Backup Code -> Copy the existing code folder into another location in your system – Vinodh Ram Mar 28 '19 at 08:26
0

I've got the same error. It is only happened because somehow I added the following line to one of my controller.ts file:

    import { element } from 'protractor';

After I removed that line, the problem was solved.

Duba
  • 78
  • 7
0

If this happens suddenly after saving your code and you are using visual studio code: Search for protractor and consider checking your created typescript files for unused imports.


You can delete them using alt+shift+o


Save your files and run ng serve, this should solve your problem

Net Monster
  • 1
  • 1
  • 1
0

just run npm install then ng serve

it worked for me :)