Skip to content
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

Error: no such file or directory /_karma_webpack_/. #230

Closed
yangit opened this issue Mar 8, 2017 · 7 comments
Closed

Error: no such file or directory /_karma_webpack_/. #230

yangit opened this issue Mar 8, 2017 · 7 comments

Comments

@yangit
Copy link

yangit commented Mar 8, 2017

I'm submitting a bug report

Webpack version:
2.2.1

Webpack Karma version:
2.0.2

Karma version:
1.5.0

Please tell us about your environment:
OSX 10.12.3

Current behavior:
Any plugin trying to write to assets folder will fail because karma webpack rewrites webpackOptions.output like so.

webpackOptions.output.path = '/_karma_webpack_/' + indexPath;
webpackOptions.output.publicPath = '/_karma_webpack_/' + publicPath;

Since that path /_karma_webpack_/... has never existed the plugin which tries to write to asset folder will fail with ENOENT can't open file error.

Expected/desired behavior:
Do not change webpackOptions.output.path so that plugins can write files to asset folder w\o any problem.

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem along with a gist/jsbin of your webpack configuration.

I had 2 plugins failing:
webpack-bundle-analyzer and sw-precache-webpack-plugin.
The first one is much easier to configure but it does not really mater. What matters is that plugins rightfully expect to get valid path in webpackOptions.output.path and they are getting some junk.

const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
webpackConfig.plugins.push(new BundleAnalyzerPlugin({
    openAnalyzer: false,
    generateStatsFile: true,
    statsFilename: 'webpack.stats.json',
    analyzerMode: 'static',
    reportFilename: 'webpack.bundleinfo.html'
  }))

With this config BundleAnalyzerPlugin will try to output 2 files in webpackOptions.output.path and will fail.

@davetron5000
Copy link

davetron5000 commented May 27, 2017

I'm also having this issue, and I can't understand how the code as written is intended to work. It appears to want to have webpack always write to /_karma_webpack_ in the root directory of the machine, which is likely never writable. output.path is treated as an absolute path

I don't see how this could've ever worked, so I'm assuming I just don't understand what this code is trying to do, so then I can figure out how to fix it or work around it.

@Luxiyalu
Copy link

Luxiyalu commented Jun 6, 2017

@davetron5000 We're running into the same problem. In karma-webpack's source, they said:

// Must have the common _karma_webpack_ prefix on path here to avoid
// https://github.com/webpack/webpack/issues/645
webpackOptions.output.path = '/_karma_webpack_/' + indexPath;
webpackOptions.output.publicPath = '/_karma_webpack_/' + publicPath;

webpack/webpack#645 was an issue back in 2014 about infinite loop due to two compilers both having outputPath set to "/".

First of all, I don't see why any project should have their output.path set to "/". Second, the solution should be to warn people against using "/" as output.path, not force rewriting karma-webpack's own output.path to another folder directly under root.

All webpack wants is an absolute path. Please allow customization at least.

Btw the webpack infinite loop issue had already been fixed.

@dentuzhik
Copy link

dentuzhik commented Jun 21, 2017

I have the same problem with a slightly different error message:

Error: EACCES: permission denied, mkdir '/_karma_webpack_'

While this is definitely legit bug, as a workaround I just stripped the BundleAnalyzer from the config which is used by karma-webpack

@Ian5015
Copy link

Ian5015 commented Jul 25, 2017

ENOENT can't open file error as well, has anyone had success finding a workaround?

@jvmccarthy
Copy link

Started running into this as well, and I think I figured out what is happening. To host files for karma, karma-webpack uses webpack-dev-middleware, which uses an in-memory file system. The /_karma_webpack/ directory only exists in the in-memory file system. However, certain plugins interpret these paths as directories on the host OS file system (the actual disk) instead of in-memory. For @dentuzhik, this was the BundleAnalyzer. For me, it was the html-webpack-plugin.

Be very careful with the webpack plugins you use with karma-webpack and remove as many plugins as you can in the webpack config used with karma-webpack. A number of plugins do not understand these in-memory file system paths.

@8bitDesigner
Copy link
Contributor

I've got a fix on my branch for this guy to point all the /_karma_webpack_/ things to /tmp/_karma_webpack_/ instead: https://github.com/Fullscreen/karma-webpack/commit/4699a43357fc5e812fc665ce84371aef2fb646ae

@izengliang
Copy link

izengliang commented Feb 25, 2018

Webpack version:

3.11.0

Webpack Karma version:

2.0.9

Karma version:

2.0.0

environment:

OSX 10.13.3

image

cd /var/folders/xv/n34wwh4j1klf_vq2w80rvv400000gn/T/_karma_webpack_/  

No such file or directory

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants