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

no such file or directory #6

Open
jhessin opened this issue Apr 12, 2018 · 1 comment
Open

no such file or directory #6

jhessin opened this issue Apr 12, 2018 · 1 comment

Comments

@jhessin
Copy link

jhessin commented Apr 12, 2018

This is what I'm trying to do.

loading this into mocha to find tests:

require('coffee-babel');
requireContext = require('require-context');

const testsContext = requireContext('./src', true, /.test.coffee$/)
testsContext.keys().forEach(testsContext);

This is the error I get:

fs.js:965
  binding.stat(pathModule.toNamespacedPath(path));
          ^

Error: ENOENT: no such file or directory, stat '/Users/jameshessin/local/websites/com.grillbrickstudios/node_modules/require-context/src'
    at Object.fs.statSync (fs.js:965:11)
    at Object.files (/Users/jameshessin/local/websites/com.grillbrickstudios/node_modules/node-dir/lib/paths.js:161:21)
    at module.exports (/Users/jameshessin/local/websites/com.grillbrickstudios/node_modules/require-context/index.js:17:6)
    at Object.<anonymous> (/Users/jameshessin/local/websites/com.grillbrickstudios/test/index.js:4:22)
    at Module._compile (internal/modules/cjs/loader.js:654:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    at Module.load (internal/modules/cjs/loader.js:566:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
    at Function.Module._load (internal/modules/cjs/loader.js:498:3)
    at Module.require (internal/modules/cjs/loader.js:598:17)
    at require (internal/modules/cjs/helpers.js:11:18)
    at /Users/jameshessin/.config/yarn/global/node_modules/mocha/lib/mocha.js:231:27
    at Array.forEach (<anonymous>:null:null)
    at Mocha.loadFiles (/Users/jameshessin/.config/yarn/global/node_modules/mocha/lib/mocha.js:228:14)
    at Mocha.run (/Users/jameshessin/.config/yarn/global/node_modules/mocha/lib/mocha.js:536:10)
    at Object.<anonymous> (/Users/jameshessin/.config/yarn/global/node_modules/mocha/bin/_mocha:582:18)
    at Module._compile (internal/modules/cjs/loader.js:654:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    at Module.load (internal/modules/cjs/loader.js:566:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
    at Function.Module._load (internal/modules/cjs/loader.js:498:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:695:10)
    at startup (internal/bootstrap/node.js:201:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:516:3)

I am using the latest version:
node: 9.11.1
npm: 5.6.0
yarn: 1.5.1
macOS: 10.13.4

@jhessin
Copy link
Author

jhessin commented Apr 12, 2018

Okay so the issue is that the context is looking in the require-context folder instead of my project root. I was able to get it working by changing the call to: requireContext('../../src', true, /\.test\.coffee$/) (Noticed I forgot to escape the . before which could be problematic).

This behavior seems counter-intuitive at best and a major bug at worst.

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

1 participant