21

I run into something really strange. Basically I am working on an angular project, I started on a different machine, then saved the project on github and today I cloned the repo onto another machine but when I run npm start I had a nice error message:

C:\Users\antobbo\Documents\angularjsProjects\todoList>npm start

> angular-quickstart@1.0.0 start C:\Users\antobbo\Documents\angularjsProjects\todoList
> tsc && concurrently "tsc -w" "lite-server"

node_modules/protractor/built/browser.d.ts(260,37): error TS2503: Cannot find namespace 'webdriver'.
node_modules/protractor/built/browser.d.ts(267,55): error TS2503: Cannot find namespace 'webdriver'.
node_modules/protractor/built/browser.d.ts(267,78): error TS2503: Cannot find namespace 'webdriver'.
node_modules/protractor/built/browser.d.ts(358,31): error TS2503: Cannot find namespace 'webdriver'.
node_modules/protractor/built/browser.d.ts(369,26): error TS2503: Cannot find namespace 'webdriver'.
node_modules/protractor/built/browser.d.ts(425,36): error TS2503: Cannot find namespace 'webdriver'.
node_modules/protractor/built/ptor.d.ts(13,29): error TS2503: Cannot find namespace 'webdriver'.

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v6.9.2
npm ERR! npm  v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! angular-quickstart@1.0.0 start: `tsc && concurrently "tsc -w" "lite-server" `
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the angular-quickstart@1.0.0 start script 'tsc && concurrently "tsc -w" "lite-server" '.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the angular-quickstart package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     tsc && concurrently "tsc -w" "lite-server"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs angular-quickstart
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls angular-quickstart
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\antobbo\Documents\angularjsProjects\todoList\npm-debug.log

It's worth noting that I have the latest version of node and npm but I did use a angular quickstart and everything worked OK on the other machine. I also have the log here So far I have uninstalled and reinstalled node again but to no avail. Does anybody have any suggestion, bearing in mind that, as I said, the application does actually work on another machine where I can start npm and run it?

EDIT: OK I thought I added a little note for beginners like me because I made a schoolboy error. I said I couldn't find any selenium webdriver in my package.json and that's because I had already run nmp install on my project - you understand I'm a really a beginner with Angular2 and nodejs - so I deleted my project completely, cloned the repo again, looked in my package.json before running any other command, found the offending line under devDependencies and changed to what it was suggested. It works now

Slava.K
  • 3,073
  • 3
  • 17
  • 28
jazzo
  • 233
  • 2
  • 9
  • Did you check in any installed modules? – ste2425 Dec 19 '16 at 23:09
  • I'm getting this same error. I'm not using angular-quickstart, but it is an angular 2 project using protractor for e2e tests which is where the issue seems to be. Something similar happened to me a couple months ago when they moved the type defs from typings to npm. I haven't found a solution yet. – Lenny Dec 20 '16 at 00:42
  • A fix is in the works on [angular/protractor#3848](https://github.com/angular/protractor/pull/3848). More discussions on this issue: [Make selenium-webdriver declaration a module](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/13382), ['npm start' error with protractor](https://github.com/angular/quickstart/issues/325) – Zeke Lu Dec 20 '16 at 15:07

4 Answers4

34

In package.json, I changed

"@types/selenium-webdriver": "^2.53.33"

to

"@types/selenium-webdriver": "2.53.33"

It compiles the TypeScript now.

Looks like there was an update published today that broke something.

https://www.npmjs.com/package/@types/selenium-webdriver

user1952133
  • 316
  • 3
  • 7
  • 3
    Worked for me. I just ran: npm install @types/selenium-webdriver@2.53.33 – Lenny Dec 20 '16 at 01:07
  • 4
    remember to run 'npm install' after updating package.json... I did not T_T – hook38 Dec 20 '16 at 01:23
  • npm install @types/selenium-webdriver@2.53.33 : work for me. Thnx @Lenny – Md. Mahmud Hasan Dec 20 '16 at 04:57
  • thanks guys. I've added the above line `"@types/selenium-webdriver": "2.53.33"` to my package.json (by the way there was no mention of selenium in it though, so I added it under devDependencies, I hope that's the right place) but to no avail, I still get the same error and when I run `npm install @types/selenium-webdriver@2.53.33` I get a ``-- @types/selenium-webdriver@2.53.33 invalid`. Would it help if I get the project from github again and try with a fresh one? This is the current package.jsn http://pastebin.com/G5aPMaSS – jazzo Dec 20 '16 at 11:43
  • OK it works fine now, sorry I was looking for selenium-webdriver after I run npm install on my application (so I added an "edit" to the original post ). Thanks a lot guys. One question though is this change likely to break the project again in the future? I mean the caret is only supposed to ensure backward compatibility right? – jazzo Dec 20 '16 at 12:30
2

The @types/selenium-webdriver published recently broke a few things in Protractor. The previous stackoverflow response works to pin this version for protractor@<=4.0.13.

This has been fixed in the latest protractor@4.0.14. Since Protractor relies that @types/selenium-webdriver works with the code base, Protractor is pinning the version of this typings file. Please checkout the latest version.

cnishina
  • 5,016
  • 1
  • 23
  • 40
0

I had this error when I tried to do "ionic serve" :

typescript: node_modules/protractor/build/browser.d.ts, line: 263 Cannot find namespace 'webdriver'.

To resolve this error, I added in package.json : "@types/selenium-webdriver": "2.53.33"

and finally I did "npm install".

It worked for me.

0

The problem could be from protractor lib which dependents on selenium-webdriver. I updated protractor lib to be "4.0.14" can it fixed the problem.

ref: Angular2 - npm install didn't find namespace webdriver

Community
  • 1
  • 1
ninetiger
  • 1,106
  • 11
  • 12