question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

I am using script

// src/test-index.js
const context = require.context('./src', true, /-test\.js$/)
context.keys().forEach(context)

And I keep running into error

> NODE_ENV=test karma start --single-run --no-auto-watch
...
ERROR [karma]: { Error: no such file or directory
    at MemoryFileSystem.readFileSync (PROJECT_ROOT/node_modules/memory-fs/lib/MemoryFileSystem.js:107:10)
    at MemoryFileSystem.readFile (PROJECT_ROOT/node_modules/memory-fs/lib/MemoryFileSystem.js:297:21)
    at doRead (PROJECT_ROOT/node_modules/karma-webpack/index.js:156:26)
    at Plugin.readFile (PROJECT_ROOT/node_modules/karma-webpack/index.js:160:3)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)
  code: 'ENOENT',
  errno: 34,
  message: 'no such file or directory',
  path: '/_karma_webpack_/test-index.js' }
Error: no such file or directory
    at MemoryFileSystem.readFileSync (PROJECT_ROOT/node_modules/memory-fs/lib/MemoryFileSystem.js:107:10)
    at MemoryFileSystem.readFile (PROJECT_ROOT/node_modules/memory-fs/lib/MemoryFileSystem.js:297:21)
    at doRead (PROJECT_ROOT/node_modules/karma-webpack/index.js:156:26)
    at Plugin.readFile (PROJECT_ROOT/node_modules/karma-webpack/index.js:160:3)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

Here is link to gist with my karma.conf.js and webpack.config.js. I’ve left other files out since these (plus the test-index.js above) are the only files involved in current process.

Node v6.2.0, npm v3.8.9 (installed via nvm). All dependencies were installed in last few hours so I am using latest versions.

Any ideas about what could be wrong or what else could I try?

Link to Stack Overflow question, if you know how to solve this and want some reputation as reward 😄

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7

github_iconTop GitHub Comments

16reactions
ufukomercommented, Jun 29, 2016

@markogresak Thank you for your answer. I got the problem. It is all about permissions! I’ve started Karma as root using the following command:

$ sudo -i
11reactions
markogresakcommented, May 23, 2016

The issue was with trying to reuse my original config for karma webpack config key.

I’ve solved the issue by changing karma config to:

webpack: {
  module: {
    loaders: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel'
      }
    ]
  },
  externals: {
    cheerio: 'window',
    'react/addons': true,
    'react/lib/ExecutionEnvironment': true,
    'react/lib/ReactContext': true
  },
  node: {
    fs: 'empty'
  }
},

What’s important here is module object and node object (to prevent Cannot find module “fs” errors). The externals part is specific to enzyme and is was copied from their Enzyme + Karma + Webpack guide. Also specific to how enzyme is working, note that there is no explicit resolve declaration since webpack automatically adds '.js' and '.json', since enzyme is internally requiring both files. An alternative would be to explicitly declare json loader.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: no such file or directory /_karma_webpack_/. · Issue #230
Current behavior: Any plugin trying to write to assets folder will fail because karma webpack rewrites webpackOptions.output like so.
Read more >
Karma webpack Error: no such file or directory ...
The issue was with trying to reuse my original config for karma webpack config key. I've solved the issue by changing karma config...
Read more >
Unit Testing - Error: no such file or directory - Karma/Jasmine
Hello,. I want to start with testing VueJS components that I wrote, but I have some issues with configuration. We are using Gulp,...
Read more >
karma-runner/karma - Gitter
I'm running karma start and I get the following error : You need to include some adapter that ... npm WARN ENOENT ENOENT:...
Read more >
Installation | webpack
Whether to use --save-dev or not depends on your use cases. Say you're using webpack only for bundling, then it's suggested that you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found