Reputation: 1147
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'.
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?
Upvotes: 6
Views: 8188
Reputation: 41
To resolve this issue I had to run this command:
npm install protractor@latest --save
Upvotes: 4
Reputation: 1
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
Upvotes: 0
Reputation: 2402
This error comes when you import from 'protactor'
rather than '@angular/platform-browser'
in your test cases.
Upvotes: 2
Reputation: 108
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.
Upvotes: 0
Reputation: 1793
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
Upvotes: 0
Reputation: 809
Run the following command in root folder of the application
npm i
ng serve
Upvotes: 0
Reputation: 984
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/[email protected]
Upvotes: 0