我更新了angular-cli
版本,我现在拥有的当前版本为1.0.0-beta.32.3 [1.0.0-beta.26]
。但是,在运行test
脚本(即npm run test
)时会抛出以下错误:
Path must be a string. Received undefined
几天前在这里发现了一个类似的问题:https://github.com/angular/angular-cli/issues/4815
对我来说似乎是一个webpack问题,但我真的不能说。我希望这可以帮助每个人遇到同样的问题。
更新
Path must be a string. Received undefined
TypeError: Path must be a string. Received undefined
at assertPath (path.js:7:11)
at Object.resolve (path.js:1146:7)
at getWebpackTestConfig (/usr/lib/node_modules/angular-cli/models/webpack-build-test.js:131:25)
at init (/usr/lib/node_modules/angular-cli/plugins/karma.js:45:25)
at Array.invoke (/home/umair/workspace/ng-portal/node_modules/di/lib/injector.js:75:15)
at Injector.get (/home/umair/workspace/ng-portal/node_modules/di/lib/injector.js:48:43)
at /home/umair/workspace/ng-portal/node_modules/karma/lib/server.js:143:20
at Array.forEach (native)
at Server._start (/home/umair/workspace/ng-portal/node_modules/karma/lib/server.js:142:21)
at Injector.invoke (/home/umair/workspace/ng-portal/node_modules/di/lib/injector.js:75:15)
at Server.start (/home/umair/workspace/ng-portal/node_modules/karma/lib/server.js:103:18)
at Promise (/home/umair/workspace/ng-portal/node_modules/@angular/cli/tasks/test.js:34:25)
at Class.run (/home/umair/workspace/ng-portal/node_modules/@angular/cli/tasks/test.js:15:16)
at Class.run (/home/umair/workspace/ng-portal/node_modules/@angular/cli/commands/test.js:38:25)
at Class.<anonymous> (/home/umair/workspace/ng-portal/node_modules/@angular/cli/ember-cli/lib/models/command.js:134:17)
at process._tickCallback (internal/process/next_tick.js:103:7)
角cli.json
{
"project": {
"version": "1.0.0-beta.26",
"name": "ng-portal"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"test": "test.ts",
"tsconfig": "tsconfig.json",
"prefix": "app",
"mobile": false,
"styles": [
"styles.css",
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
"../node_modules/font-awesome/css/font-awesome.css"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"addons": [
"../node_modules/font-awesome/fonts/*.+(otf|eot|svg|ttf|woff|woff2)"
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"prefixInterfaces": false,
"inline": {
"style": false,
"template": false
},
"spec": {
"class": false,
"component": true,
"directive": true,
"module": false,
"pipe": true,
"service": true
}
}
}
答案 0 :(得分:0)
我有同样的问题,更新karma.conf.js修复它,如下所述:https://github.com/angular/angular-cli/issues/4815
将angular-cli
替换为@angular/cli
中的karma.conf.js
,您应该好好去。