在Angular 5版本中使用Protractor。 当我运行“ng e2e”时,有两个错误:
错误一:E / launcher - 错误:TSError:⨯无法编译TypeScript
错误二:E / launcher - 进程已退出,错误代码为100
这是node_modules / Protractor中tsconfig.json中的错误:
这是Package.json文件:
{
"name": "nanoguits",
"version": "1.2.9",
"license": "MIT",
"scripts": {
"ng": "ng",
"serve": "ng serve --delete-output-path=false",
"build": "ng build --prod && ngc",
"start": "ng serve",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^4.3.4",
"@angular/common": "^4.3.4",
"@angular/compiler": "^4.3.4",
"@angular/core": "^4.3.4",
"@angular/forms": "^4.3.4",
"@angular/http": "^4.3.4",
"@angular/platform-browser": "^4.3.4",
"@angular/platform-browser-dynamic": "^4.3.4",
"@angular/platform-server": "^4.3.4",
"@angular/router": "^4.3.4",
"@types/file-saver": "0.0.1",
"angular2-jwt": "^0.2.2",
"bootstrap": "4.0.0-alpha.5",
"c3": "^0.4.11",
"core-js": "^2.5.0",
"d3": "~3.5.0",
"file-saver": "^1.3.3",
"font-awesome": "^4.7.0",
"lodash": "^4.17.4",
"moment": "^2.15.2",
"ng2-bootstrap": "~1.4.2",
"ngx-captcha": "^1.2.4",
"postscribe": "^2.0.8",
"reflect-metadata": "^0.1.3",
"rxjs": "^5.4.3",
"web-animations-js": "^2.3.1",
"zone.js": "^0.8.16"
},
"devDependencies": {
"@angular/cli": "^1.6.6",
"@angular/compiler-cli": "^4.3.4",
"@angular/language-service": "^4.3.4",
"@types/jasmine": "^2.6.0",
"@types/jasminewd2": "~2.0.2",
"@types/lodash": "^4.14.74",
"@types/node": "^8.0.10",
"codelyzer": "~3.0.1",
"electron": "^1.4.1",
"file-loader": "^0.9.0",
"jasmine-core": "~2.6.4",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage": "^1.0.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"node-sass": "^4.7.2",
"protractor": "~5.1.2",
"ts-node": "~3.0.4",
"tslint": "~5.6.0",
"typescript": "^2.4.2"
}
Protractor.conf.js文件:
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
chromeOnly: true,
directConnect: true,
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome',
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function () { }
},
onPrepare() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
- 这是控制台日志,你可以在那里找到错误:
E/launcher - Error: TSError: ⨯ Unable to compile TypeScript
Cannot find type definition file for 'jasmine'. (2688)
Cannot find type definition file for 'jasminewd2'. (2688)
Cannot find type definition file for 'node'. (2688)
e2e/app.e2e-spec.ts (1,34): Cannot find module './app.po'. (2307)
e2e/app.e2e-spec.ts (2,38): Cannot find module 'protractor'. (2307)
e2e/app.e2e-spec.ts (4,1): Cannot find name 'describe'. (2304)
e2e/app.e2e-spec.ts (7,3): Cannot find name 'beforeEach'. (2304)
e2e/app.e2e-spec.ts (11,3): Cannot find name 'it'. (2304)
e2e/app.e2e-spec.ts (13,5): Cannot find name 'expect'. (2304)
at getOutput (/Users/nikolatrajkovic/Desktop/Workspace/nano-projects/nanoguits/node_modules/ts-node/src/index.ts:300:15)
at /Users/nikolatrajkovic/Desktop/Workspace/nano-projects/nanoguits/node_modules/ts-node/src/index.ts:330:16
at Object.compile (/Users/nikolatrajkovic/Desktop/Workspace/nano-projects/nanoguits/node_modules/ts-node/src/index.ts:489:17)
at Module.m._compile (/Users/nikolatrajkovic/Desktop/Workspace/nano-projects/nanoguits/node_modules/ts-node/src/index.ts:382:43)
at Module._extensions..js (module.js:663:10)
at Object.require.extensions.(anonymous function) [as .ts] (/Users/nikolatrajkovic/Desktop/Workspace/nano-projects/nanoguits/node_modules/ts-node/src/index.ts:385:12)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at /Users/nikolatrajkovic/Desktop/Workspace/nano-projects/nanoguits/node_modules/jasmine/lib/jasmine.js:93:5
at Array.forEach (<anonymous>)
at Jasmine.loadSpecs (/Users/nikolatrajkovic/Desktop/Workspace/nano-projects/nanoguits/node_modules/jasmine/lib/jasmine.js:92:18)
at Jasmine.execute (/Users/nikolatrajkovic/Desktop/Workspace/nano-projects/nanoguits/node_modules/jasmine/lib/jasmine.js:197:8)
at /Users/nikolatrajkovic/Desktop/Workspace/nano-projects/nanoguits/node_modules/protractor/built/frameworks/jasmine.js:132:15
[16:16:58] E/launcher - Process exited with error code 100
Any idea about the problem?
答案 0 :(得分:2)
第一期:
npm install ts-node --save-de
npm install -g typescript --save-dev
第二次添加:
chromeOnly:true
directConnect: true
关于量角器配置