简体   繁体   English

在测试执行后,将npm作为脚本“ npm run protractor”运行,会抛出控制台错误

[英]Running npm as a script “npm run protractor” throw console errors after test execution

We recently decided to control easy installation of protractor on local machines (by specifying it in package.json) instead of installing individually with -g flag. 我们最近决定控制量角器在本地计算机上的轻松安装(通过在package.json中指定),而不是使用-g标志单独安装。 So addition is something like this 所以加法是这样的

"scripts": {
    "protractor": "protractor protractor.config.js --directConnect"
}

After that when I try to execute protractor using npm run protractor 之后,当我尝试使用npm执行量角器时,运行量角器

It gives following console error after running tests. 运行测试后,它会显示以下控制台错误。

npm ERR! npm ERR! Failed at the @ protractor script 'sudo protractor protractor.config.js --directConnect'. @ protractor脚本'sudo protractor protractor.config.js --directConnect'失败。 npm ERR! npm ERR! This is most likely a problem with the package, npm ERR! 这很可能是软件包npm ERR的问题! not with npm itself. 不与npm本身。 .... .... .... ....

Running protractor using following command works fine. 使用以下命令运行量角器可以正常工作。

node_modules/protractor/bin/protractor protractor.config.js --directConnect

Also it works ok if protractor is installed as global package and run as below 如果量角器作为全局软件包安装并按以下方式运行,也可以正常工作

protractor protractor.config.js --directConnect

Only problem that running it as scripts always gives errors after tests run is finished. 测试运行完成后,将其作为脚本运行始终会给出错误的唯一问题。

change you script: 更改您的脚本:

"scripts": {
    "test": "protractor protractor.config.js --directConnect"
}

and then use npm test to give a try 然后使用npm test进行尝试

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

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