-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Path must be a string. Received [ 'js/main.spec.js', #350
Comments
I'm brand new to using karma-webpack and ran into this issue yesterday while trying to set up my environment. Is there a version that would be better to use, while this gets looked at? Thanks! |
@rythos42 3.0.0 is working fine for me. |
+1 I also found this bug, I've fallback to 3.0.0. |
* by reverting broken "karma-webpack" 3.0.2=>3.0.1, codymikol/karma-webpack#350
Facing the same error running [email protected] on Windows OS, see output here. [email protected] doesn't have such problem, but it requires this workaround. |
the problem is it is this line: The problem is not line 255 itself, that is just where it occurs.
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 |
I've also met this (or similar) issue. In my case it occured when I was using karma in autowatch mode. The value of
|
This can be encountered if a preprocessor beforehand has already produced multiple outputs, too. For example, sourcemaps preprocessing will result in |
console.log(this.entries);
/* =>
{
'apps\\front-end\\src\\_assets\\debug\\root.spec': 'apps/front-end/src/_assets/debug/root.spec.tsx',
'apps\\front-end\\src\\_assets\\main\\main.spec': 'apps/front-end/src/_assets/main/main.spec.tsx'
}
*/
console.log(entry);
// => "apps\\front-end\\src\\_assets\\main\\main.spec"
// NOTE: the file extension `.tsx` is not present
console.log(entryPath);
// => "apps/front-end/src/_assets/main/main.spec.tsx"
// ... later in the file
console.log(file);
// => "apps\\front-end\\src\\_assets\\main\\main.spec.tsx"
console.log(this.outputs);
/* =>
{
'apps/front-end/src/_assets/debug/root.spec.tsx': [
'_assets/bundles/apps\\front-end\\src\\_assets\\debug\\root.spec/apps\\front-end\\src\\_assets\\debug\\root.spec.js',
'_assets/bundles/apps\\front-end\\src\\_assets\\debug\\root.spec/apps\\front-end\\src\\_assets\\debug\\root.spec.js.map'
],
'apps/front-end/src/_assets/main/main.spec.tsx': [
'_assets/bundles/apps\\front-end\\src\\_assets\\main\\main.spec/apps\\front-end\\src\\_assets\\main\\main.spec.js',
'_assets/bundles/apps\\front-end\\src\\_assets\\main\\main.spec/apps\\front-end\\src\\_assets\\main\\main.spec.js.map'
]
}
*/
// For context, here is a relevant portion of the webpack configuration:
/*
{
...
output: {
path: PATH_TO_DIST,
publicPath: '/',
filename: IS_PRODUCTION_ENV
? '_assets/bundles/[name]/[name].[hash:20].js'
: '_assets/bundles/[name]/[name].js'
}
...
}
*/ A change similar to this might fix the issue: var entryPath = this.entries[entry]
var outputPath = stats.assetsByChunkName[entry]
- this.outputs[entryPath] = outputPath
+ var entryPathNormalized = entryPath.replace(/\//g, path.sep)
+ this.outputs[entryPathNormalized] = outputPath
The above is a first step, the final fix may be more involved. |
I took another look at the original post. It looks like my issue is separate (but similar) to this one, where instead of receiving an unexpected array (like the OP), it is receiving |
but this doesn't support webpack 4, does it? is there any workaround for webpack 4 users? this issue effectively broke all our CI builds/PRs. |
Yes, there are two issues. One is the mismatch of path separators (#353 and #351 are related). Simple to fix. The other is that chunks can have multiple assets so edit: @thijstriemstra webpack 4 and 3.0.0 do work together (its what im using now until these get fixed). |
Will get a fix out asap |
@thijstriemstra well I'm on webpack ^4 and karma-webpack 3.0.0, and my tests run. ¯\_(ツ)_/¯ |
@MayhemYDG oh damn, i'll try that, cheers. Update: same results, wtf
|
Could not update karma-webpack to latest as it was not running because of an error: The "path" argument must be of type string. Received type object codymikol/karma-webpack#350
Could not update karma-webpack to latest as it was not running because of an error: The "path" argument must be of type string. Received type object codymikol/karma-webpack#350
@thijstriemstra I get the same error on karma-webpack 3.0.2. |
Er, I'm still getting the same error reported by the OP in 3.0.3 |
@michael-ciniawsky only one of the two issues was fixed. the other issue was that a source can have multiple assets so the output entry may be an array. |
Released in |
Could not update karma-webpack to latest as it was not running because of an error: The "path" argument must be of type string. Received type object codymikol/karma-webpack#350
I'm still seeing the same issue on
|
Note to maintainer: let us test your fixes first instead of putting out new buggy releases? |
@thijstriemstra Sure, do you want to be the new maintainer of this plugin and write the tests ? 😛 I'm only administrating here... @kirschre #355 (it's a different known bug, introduced by ab4dde9, e.g when using sourcemaps) |
No but put out a release candidate for testing first. Oh well. |
Or revert regressions. 🤔 |
I have also seen this issue with sourcemap generation disabled but with a JS file that imports SASS: ERROR [karma]: TypeError: Path must be a string. Received [ 'src\components\person\person.test.css', |
Yep, setting 'devtool' to 'none' fixed this issue for me. |
codymikol/karma-webpack#350 Not sure yet of any side effects.
Same issue in 3.0.5, so staying on 3.0.0. Mac and linux OSes |
Confirming that this is still an issue on 3.0.5 running Ubuntu 16.04 and 18.04. |
@thijstriemstra hope it helps Fixed "path" error with DeprecationWarning is gone with |
@npetruzzelli were you able to resolve this? for now I just pinned to version 3.0.0 and it works |
@elliotykim - I have not been able to explore the issue further nor have I been able to contribute to resolving it. Life has kept me busy with other things. I have not been able to test if updates have resolved the issue. My work around is exactly the same as you in that I explicitly use:
|
Still seeing this in 3.0.5 and in 4.0.0-rc.6. The test failures are intermittent however for me. |
Why is this closed? Still having the same issue with 3.0.5. Have to pin hard to 3.0.0 and it works. |
@michael-ciniawsky should this still stay closed? Seems like people are still coming in with issues. Likewise seeing intermittent test failures. We are running
|
I created a new ticket with a possible solution to the problem. See #422 and the "Workaround" section |
* by reverting broken "karma-webpack" 3.0.2=>3.0.1, codymikol/karma-webpack#350
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)
Code
https://gist.github.com/casufi/f298bcab3f2f95a82616591446e380de
How Do We Reproduce?
The text was updated successfully, but these errors were encountered: