今天我正在将Angular RC 6应用程序更新为新发布的最终版本。一切都运转良好,但是我和Protractor有问题。我收到以下错误:
server.listen(port, opt_host, function() {
TypeError: Cannot read property 'listen' of undefined
我从该应用程序的先前版本更改的是package.json
文件。我猜这是一个配置问题,但我似乎无法找到有关Protractor配置的任何改变。
此外,我在此应用程序中使用了webpack - 我不知道它是否与webpack有关。也许某人在webpack和Angular 2 Final版本上遇到了一些问题。
protractor.conf.js
'use strict';
require('ts-node/register');
require('core-js/es6');
require('reflect-metadata');
require("zone.js/dist/zone-node");
var helpers = require('./helpers');
exports.config = {
baseUrl: 'http://localhost:8080/yii/application/test_backend_mvc/branches/INT-81_RD/ng-app/dist/',
// use `npm run e2e`
specs: [
helpers.root('src/**/**.e2e.ts'),
helpers.root('src/**/*.e2e.ts')
],
exclude: [],
framework: 'jasmine2',
allScriptsTimeout: 110000,
jasmineNodeOpts: {
showTiming: true,
showColors: true,
isVerbose: false,
includeStackTrace: false,
defaultTimeoutInterval: 400000
},
directConnect: true,
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
'args': ['show-fps-counter=true']
}
},
onPrepare: function() {
browser.ignoreSynchronization = true;
},
/**
* Angular 2 configuration
*
* useAllAngular2AppRoots: tells Protractor to wait for any angular2 apps on the page instead of just the one matching
* `rootEl`
*/
useAllAngular2AppRoots: true
};
NPM-的debug.log
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'protractor' ]
2 info using npm@3.10.3
3 info using node@v6.5.0
4 verbose run-script [ 'preprotractor', 'protractor', 'postprotractor' ]
5 info lifecycle test-ui-prototype@1.0.0~preprotractor: test-ui-prototype@1.0.0
6 silly lifecycle test-ui-prototype@1.0.0~preprotractor: no script for preprotractor, continuing
7 info lifecycle test-ui-prototype@1.0.0~protractor: test-ui-prototype@1.0.0
8 verbose lifecycle test-ui-prototype@1.0.0~protractor: unsafe-perm in lifecycle true
9 verbose lifecycle test-ui-prototype@1.0.0~protractor: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;c:\xampp\htdocs\yii\application\test_backend_mvc\branches\INT-81_RD\ng-app\node_modules\.bin;C:\Program Files\nodejs;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Skype\Phone\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Microsoft\Web Platform Installer\;c:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files (x86)\MySQL\MySQL Fabric 1.5 & MySQL Utilities 1.5\;C:\Program Files (x86)\MySQL\MySQL Fabric 1.5 & MySQL Utilities 1.5\Doctrine extensions for PHP\;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Windows\system32\config\systemprofile\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\nodejs\;;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Users\daniel.grima\AppData\Roaming\npm
10 verbose lifecycle test-ui-prototype@1.0.0~protractor: CWD: c:\xampp\htdocs\yii\application\test_backend_mvc\branches\INT-81_RD\ng-app
11 silly lifecycle test-ui-prototype@1.0.0~protractor: Args: [ '/d /s /c', 'protractor' ]
12 silly lifecycle test-ui-prototype@1.0.0~protractor: Returned: code: 1 signal: null
13 info lifecycle test-ui-prototype@1.0.0~protractor: Failed to exec protractor script
14 verbose stack Error: test-ui-prototype@1.0.0 protractor: `protractor`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:242:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:877:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid test-ui-prototype@1.0.0
16 verbose cwd c:\xampp\htdocs\yii\application\test_backend_mvc\branches\INT-81_RD\ng-app
17 error Windows_NT 10.0.10586
18 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "protractor"
19 error node v6.5.0
20 error npm v3.10.3
21 error code ELIFECYCLE
22 error test-ui-prototype@1.0.0 protractor: `protractor`
22 error Exit status 1
23 error Failed at the test-ui-prototype@1.0.0 protractor script 'protractor'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the test-ui-prototype package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error protractor
23 error You can get information on how to open an issue for this project with:
23 error npm bugs test-ui-prototype
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls test-ui-prototype
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]
的package.json
{
"name": "test-ui-prototype",
"version": "1.0.0",
"scripts": {
"start": "webpack-dev-server --inline --progress --profile --bail --port 8581",
"lite": "lite-server",
"build:dev": "rimraf dist && webpack --config config/webpack.dev.js --progress --profile --bail",
"build:prod": "rimraf dist && webpack --config config/webpack.prod.js --progress --profile --bail",
"postinstall": "typings install",
"tsc": "tsc",
"tsc:w": "tsc -w",
"typings": "typings",
"test": "gulp test",
"watch": "gulp tdd",
"test:karma": "karma start",
"watch:karma": "npm run test:karma -- --auto-watch --no-single-run",
"e2e": "npm run protractor",
"e2e:live": "npm run e2e -- --elementExplorer",
"lint": "gulp tslint",
"tslint": "tslint -c tslint.json src/**/*.ts",
"protractor": "protractor",
"pree2e": "npm run webdriver:update -- --standalone",
"ci": "npm run lint && npm test && npm run e2e",
"webdriver-manager": "webdriver-manager",
"webdriver:update": "npm run webdriver-manager update",
"webdriver:start": "npm run webdriver-manager start"
},
"dependencies": {
"@angular/common": "2.0.0",
"@angular/compiler": "2.0.0",
"@angular/core": "2.0.0",
"@angular/forms": "2.0.0",
"@angular/http": "2.0.0",
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/router": "3.0.0",
"@angular/upgrade": "2.0.0",
"angular2-in-memory-web-api": "0.0.20",
"angular2-jwt": "^0.1.16",
"es6-shim": "^0.35.0",
"jquery": "^2.2.4",
"ng2-cookies": "^0.1.9",
"ts-node": "^0.9.3",
"primeng": "1.0.0-beta.15",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.12",
"core-js": "^2.4.0",
"zone.js": "^0.6.17"
},
"devDependencies": {
"ts-promise": "^0.3.0",
"codelyzer": "0.0.22",
"concurrently": "^2.0.0",
"css-loader": "^0.23.1",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.9.0",
"gulp": "^3.9.1",
"gulp-tslint": "^5.0.0",
"html-loader": "^0.4.3",
"html-webpack-plugin": "^2.22.0",
"jasmine-core": "^2.4.1",
"karma": "^1.1.0",
"karma-chrome-launcher": "^1.0.1",
"karma-coverage": "^1.0.0",
"karma-firefox-launcher": "^1.0.0",
"karma-html-reporter": "^0.2.7",
"karma-jasmine": "^1.0.2",
"karma-phantomjs-launcher": "^1.0.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^1.7.0",
"lite-server": "^2.2.0",
"null-loader": "^0.1.1",
"phantomjs-prebuilt": "^2.1.7",
"protractor": "^3.2.2",
"raw-loader": "^0.5.1",
"rimraf": "^2.5.2",
"style-loader": "^0.13.1",
"ts-loader": "^0.8.1",
"tslint": "^3.10.2",
"tslint-loader": "^2.1.4",
"typescript": "^1.8.10",
"typings": "^1.3.1",
"webpack": "^1.13.1",
"webpack-dev-server": "^1.14.1",
"webpack-merge": "^0.14.0"
}
}
更新 - 进一步测试
出于测试目的,我使用angular-cli
和Webpack创建了一个新项目。我这样做是为了验证我的应用程序中的配置是否有任何问题。我没有注意到任何与众不同的东西。我唯一尝试过的是将protractor
更新为最新版本4.0.5
。不幸的是,我得到了相同的结果:Cannot read property 'listen' of undefined
> test-ui-prototype@1.0.0 protractor c:\xampp\htdocs\yii\application\test_backend_mvc\branches\INT-81_RD\ng-app
> protractor
[16:41:24] I/direct - Using ChromeDriver directly...
[16:41:24] I/launcher - Running 1 instances of WebDriver
[16:41:24] E/launcher - Cannot read property 'listen' of undefined
[16:41:24] E/launcher - TypeError: Cannot read property 'listen' of undefined
at isFree (c:\xampp\htdocs\yii\application\test_backend_mvc\branches\INT-81_RD\ng-app\node_modules\selenium-webdriver\net\portprober.js:171:9)
at findPort (c:\xampp\htdocs\yii\application\test_backend_mvc\branches\INT-81_RD\ng-app\node_modules\selenium-webdriver\net\portprober.js:203:7)
at c:\xampp\htdocs\yii\application\test_backend_mvc\branches\INT-81_RD\ng-app\node_modules\selenium-webdriver\net\portprober.js:192:5
at ManagedPromise.invokeCallback_ (c:\xampp\htdocs\yii\application\test_backend_mvc\branches\INT-81_RD\ng-app\node_modules\selenium-webdriver\lib\promise.js:1379:14)
at TaskQueue.execute_ (c:\xampp\htdocs\yii\application\test_backend_mvc\branches\INT-81_RD\ng-app\node_modules\selenium-webdriver\lib\promise.js:2913:14)
at TaskQueue.executeNext_ (c:\xampp\htdocs\yii\application\test_backend_mvc\branches\INT-81_RD\ng-app\node_modules\selenium-webdriver\lib\promise.js:2896:21)
at asyncRun (c:\xampp\htdocs\yii\application\test_backend_mvc\branches\INT-81_RD\ng-app\node_modules\selenium-webdriver\lib\promise.js:2775:27)
at c:\xampp\htdocs\yii\application\test_backend_mvc\branches\INT-81_RD\ng-app\node_modules\selenium-webdriver\lib\promise.js:639:7
at ZoneDelegate.invoke (c:\xampp\htdocs\yii\application\test_backend_mvc\branches\INT-81_RD\ng-app\node_modules\zone.js\dist\zone-node.js:203:28)
at Zone.run (c:\xampp\htdocs\yii\application\test_backend_mvc\branches\INT-81_RD\ng-app\node_modules\zone.js\dist\zone-node.js:96:43)
[16:41:24] E/launcher - Process exited with error code 199