2017-02-26 73 views
1

我更新了angular-cli版本,而我現在使用的版本是1.0.0-beta.32.3 [1.0.0-beta.26]。然而,在運行test腳本即npm run test它引發以下錯誤:angular-cli路徑必須是字符串。收到undefined

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

哪條路徑必須是字符串? – sandrooco

+0

上次我看到這個錯誤時,我試圖加載一個我沒有放進.angular-cli.json環境數組中的自定義環境。您是否在代碼中使用自定義環境?編輯 - 另外,它可能就像你不小心刪除了environment.test.ts文件一樣簡單 – peppermcknight

+0

@Sandrooco添加了完整的錯誤跟蹤。 – Umair

回答

相關問題