简体   繁体   English

运行“npm start”由于错误而失败 - Angular2

[英]Running “npm start” fails due to error - Angular2

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: 基本上我正在开展一个角度项目,我开始使用不同的机器,然后将项目保存在github上,今天我将repo克隆到另一台机器上,但是当我运行npm start时,我收到了一条很好的错误消息:

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. 值得注意的是,我有最新版本的节点和npm,但我确实使用了一个角度快速启动,一切都在另一台机器上运行正常。 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? 有没有人有任何建议,请记住,正如我所说,应用程序确实可以在另一台机器上工作,我可以在这台机器上运行npm并运行它?

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. 我说我在package.json中找不到任何selenium webdriver,那是因为我已经在我的项目上运行了nmp install - 你知道我是一个真正的Angular2和nodejs的初学者 - 所以我完全删除了我的项目,克隆再次使用repo,在运行任何其他命令之前查看我的package.json,在devDependencies下找到有问题的行并更改为它的建议。 It works now 它现在有效

In package.json, I changed 在package.json中,我改变了

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

to

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

It compiles the TypeScript now. 它现在编译TypeScript。

Looks like there was an update published today that broke something. 看起来今天发布的更新打破了一些东西。

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

The @types/selenium-webdriver published recently broke a few things in Protractor. 最近发布的@types/selenium-webdriver在Protractor中打破了一些东西。 The previous stackoverflow response works to pin this version for protractor@<=4.0.13 . 之前的stackoverflow响应用于将此版本固定为protractor@<=4.0.13

This has been fixed in the latest protractor@4.0.14 . 这已在最新的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. 由于Protractor依赖@types/selenium-webdriver与代码库一起工作,因此Protractor固定了这个打字文件的版本。 Please checkout the latest version. 请查看最新版本。

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'. typescript:node_modules / protractor / build / browser.d.ts,line:263找不到命名空间'webdriver'。

To resolve this error, I added in package.json : "@types/selenium-webdriver": "2.53.33" 为了解决这个错误,我在package.json中添加了:“@ types / selenium-webdriver”:“2.53.33”

and finally I did "npm install". 最后我做了“npm install”。

It worked for me. 它对我有用。

The problem could be from protractor lib which dependents on selenium-webdriver. 问题可能来自量子器lib,它依赖于selenium-webdriver。 I updated protractor lib to be "4.0.14" can it fixed the problem. 我更新了量角器lib为“4.0.14”可以解决问题。

ref: Angular2 - npm install didn't find namespace webdriver ref: Angular2 - npm install没有找到命名空间webdriver

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM