karma-webpack: TypeError: Path must be a string. Received [ 'js/main.spec.js',

x「wdm」: wait until bundle finished: noop 03 09 2018 10:51:35.026:ERROR [karma]: TypeError: Path must be a string. Received [ 'js/main.spec.js', 'css/tiscc.min.css', 'js/main.spec.js.map', 'css/tiscc.min.css.map' ] at assertPath (path.js:28:11) at Object.join (path.js:1236:7) at Plugin.<anonymous> (/builds/tis/tis/tiscommandcenter/node_modules/karma-webpack/lib/karma-webpack.js:262:68) at Plugin.readFile (/builds/tis/tis/tiscommandcenter/node_modules/karma-webpack/lib/karma-webpack.js:281:5) at _combinedTickCallback (internal/process/next_tick.js:131:7) at process._tickCallback (internal/process/next_tick.js:180:9)

  • Operating System: Windows 10
  • Node Version: v8.11.3
  • NPM Version: 6.4.0
  • webpack Version: 4.17.1
  • karma-webpack Version: 3.0.2

Code

https://gist.github.com/casufi/f298bcab3f2f95a82616591446e380de

How Do We Reproduce?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 24
  • Comments: 36 (4 by maintainers)

Commits related to this issue

Most upvoted comments

Note to maintainer: let us test your fixes first instead of putting out new buggy releases?

@rythos42 3.0.0 is working fine for me.

I’m still seeing the same issue on 3.0.4 (tests succeed on 3.0.0):

07 09 2018 12:30:23.322:ERROR [karma]: TypeError: Path must be a string. Received [ 'path/to/karma_index.bundle.js',
  'path/to/karma_index.bundle.js.map' ]
    at assertPath (path.js:28:11)
    at Object.join (path.js:1236:7)
    at Plugin.<anonymous> (path/to/node_modules/karma-webpack/lib/karma-webpack.js:266:68)
    at Plugin.readFile (path/to/karma-webpack/lib/karma-webpack.js:285:5)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
ℹ 「wdm」: Hash: 95085f23983f7eeef8e0
Version: webpack 4.17.2
Time: 22273ms
Built at: 2018-09-07 11:30:23

the problem is it is this line:

https://github.com/webpack-contrib/karma-webpack/blob/d2f5a538d864e7b1f4bb431324de67be1ccbb51d/src/karma-webpack.js#L255

The problem is not line 255 itself, that is just where it occurs.

file is a file system path that is normalized to the operating system, meaning the path seperator on Windows is \ BUT the keys in this.outputs always uses the forward slash / regardless of the operating system. so the result of this.outputs[file] will always be undefined.

This will always be a problem on Windows. It will just happen to work on POSIX systems, but its fragile.

It appears this is a new issue. I was recently using 3.0.0 without any problems, when someone went to review my code "karma-webpack": "^3.0.0" in package.json resolved to 3.0.2 and the errors started.

Same issue in 3.0.5, so staying on 3.0.0. Mac and linux OSes

Er, I’m still getting the same error reported by the OP in 3.0.3

Confirming that this is still an issue on 3.0.5 running Ubuntu 16.04 and 18.04.

This can be encountered if a preprocessor beforehand has already produced multiple outputs, too.

For example, sourcemaps preprocessing will result in ['foo.js', 'foo.js.map'].

Yep, setting ‘devtool’ to ‘none’ fixed this issue for me.

@MayhemYDG oh damn, i’ll try that, cheers.

Update: same results, wtf

> wavesurfer.js@2.0.7 test /home/thijs/projects/wavesurfer.js
> karma start karma.conf.js

(node:4394) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
    at Plugin.<anonymous> (/home/thijs/projects/wavesurfer.js/node_modules/karma-webpack/lib/karma-webpack.js:109:14)
    at Array.forEach (<anonymous>)
    at Plugin (/home/thijs/projects/wavesurfer.js/node_modules/karma-webpack/lib/karma-webpack.js:108:16)
    at invoke (/home/thijs/projects/wavesurfer.js/node_modules/di/lib/injector.js:75:15)
    at Array.instantiate (/home/thijs/projects/wavesurfer.js/node_modules/di/lib/injector.js:59:20)
    at get (/home/thijs/projects/wavesurfer.js/node_modules/di/lib/injector.js:48:43)
    at /home/thijs/projects/wavesurfer.js/node_modules/di/lib/injector.js:71:14
    at Array.map (<anonymous>)
    at Array.invoke (/home/thijs/projects/wavesurfer.js/node_modules/di/lib/injector.js:70:31)
    at Injector.get (/home/thijs/projects/wavesurfer.js/node_modules/di/lib/injector.js:48:43)
    at instantiatePreprocessor (/home/thijs/projects/wavesurfer.js/node_modules/karma/lib/preprocessor.js:50:20)
    at Array.forEach (<anonymous>)
    at createPreprocessor (/home/thijs/projects/wavesurfer.js/node_modules/karma/lib/preprocessor.js:68:20)
    at Array.invoke (/home/thijs/projects/wavesurfer.js/node_modules/di/lib/injector.js:75:15)
    at get (/home/thijs/projects/wavesurfer.js/node_modules/di/lib/injector.js:48:43)
    at /home/thijs/projects/wavesurfer.js/node_modules/di/lib/injector.js:71:14
ℹ 「wdm」: wait until bundle finished: noop
ℹ 「wdm」: wait until bundle finished: noop
ℹ 「wdm」: wait until bundle finished: noop
ℹ 「wdm」: wait until bundle finished: noop
06 09 2018 17:25:33.856:ERROR [karma]: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string
    at assertPath (path.js:39:11)
    at Object.join (path.js:1158:7)
    at Plugin.<anonymous> (/home/thijs/projects/wavesurfer.js/node_modules/karma-webpack/lib/karma-webpack.js:262:68)
    at Plugin.readFile (/home/thijs/projects/wavesurfer.js/node_modules/karma-webpack/lib/karma-webpack.js:281:5)
    at process._tickCallback (internal/process/next_tick.js:176:11)
06 09 2018 17:25:33.858:ERROR [karma]: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string
    at assertPath (path.js:39:11)
    at Object.join (path.js:1158:7)
    at Plugin.<anonymous> (/home/thijs/projects/wavesurfer.js/node_modules/karma-webpack/lib/karma-webpack.js:262:68)
    at Plugin.readFile (/home/thijs/projects/wavesurfer.js/node_modules/karma-webpack/lib/karma-webpack.js:281:5)
    at process._tickCallback (internal/process/next_tick.js:176:11)
06 09 2018 17:25:33.859:ERROR [karma]: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string
    at assertPath (path.js:39:11)
    at Object.join (path.js:1158:7)
    at Plugin.<anonymous> (/home/thijs/projects/wavesurfer.js/node_modules/karma-webpack/lib/karma-webpack.js:262:68)
    at Plugin.readFile (/home/thijs/projects/wavesurfer.js/node_modules/karma-webpack/lib/karma-webpack.js:281:5)
    at process._tickCallback (internal/process/next_tick.js:176:11)
06 09 2018 17:25:33.859:ERROR [karma]: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string
    at assertPath (path.js:39:11)
    at Object.join (path.js:1158:7)
    at Plugin.<anonymous> (/home/thijs/projects/wavesurfer.js/node_modules/karma-webpack/lib/karma-webpack.js:262:68)
    at Plugin.readFile (/home/thijs/projects/wavesurfer.js/node_modules/karma-webpack/lib/karma-webpack.js:281:5)
    at process._tickCallback (internal/process/next_tick.js:176:11)
ℹ 「wdm」: 
ℹ 「wdm」: Compiled successfully.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! wavesurfer.js@2.0.7 test: `karma start karma.conf.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the wavesurfer.js@2.0.7 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

@thijstriemstra hope it helps

Fixed “path” error with var webpackConfig = require('./build-config/webpack.prod.main.js'); webpackConfig.devtool = 'none'; in karma.conf.js

DeprecationWarning is gone with "karma-webpack": "^4.0.0-rc.2"

Or revert regressions. 🤔

@thijstriemstra I get the same error on karma-webpack 3.0.2. Make sure you install version 3.0.0 exactly. Delete your node_modules and lock files, re-install your npm dependencies, and retry.

Will get a fix out asap

This can be encountered if a preprocessor beforehand has already produced multiple outputs, too.

For example, sourcemaps preprocessing will result in ['foo.js', 'foo.js.map'].