Karma不会将node_module / * / package.json加载到PhantomJS(404错误)

时间:2016-10-26 00:34:04

标签: angularjs phantomjs karma-runner

我正在使用Karma 0.13.22  节点v6.7.0  npm 3.10.3  和PhantomJS 2.1.1

使用角度2种子作为基础,当我运行npm测试时,我收到以下错误:

25 10 2016 20:08:29.857:INFO [PhantomJS 2.1.1 (Windows 7 0.0.0)]: Connected on socket 3G6Eu905pwciAA 3BAAAA with id 70262326
25 10 2016 20:08:30.128:WARN [web-server]:404: /node_modules/@angular/core/package.json
25 10 2016 20:08:30.131:WARN [web-server]: 404: /node_modules/@angular/platform-browser-dynamic/pack age.json
PhantomJS 2.1.1 (Windows 7 0.0.0) ERROR: '(SystemJS) XHR error (404 Not Found) loading http://localhost:9876/node_modules/@angular/core/package.json
Error loading http://localhost:9876/node_modules/@angular/core/package.json'

我尝试在我的karma.conf.js中将所有json文件包含在一个模式中,但是没有用。  据我所知,我有正确的baseURL和basePath。

我想知道如何解决这个问题?

更新:如果我使用baseURL:'/ base /'

我收到错误:

26 10 2016 08:33:13.764:WARN [web-server]: 404: /base/node_modules/ng2-translate.js
26 10 2016 08:33:13.809:WARN [web-server]: 404: /base/node_modules/lodash.js
PhantomJS 2.1.1 (Windows 7 0.0.0) ERROR: '(SystemJS) XHR error (404 Not    Found) loading http://localhost:9876/base/node_modules/ng2-translate.js
    Error loading http://localhost:9876/base/node_modules/ng2-translate.js as "ng2-translate" from http://localhost:9876/base/dist/dev/app/app.component.js' 

我尝试通过添加

解决此问题
{ pattern: 'node_modules/@angular/*.js', included: false, watched: false },
{ pattern: 'node_modules/*.js', included: false, watched: false },
'node_modules/ng2-translate.js'

到我的karma.conf.js,但这没有解决问题

0 个答案:

没有答案