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

"Cannot read property 'filename' of undefined" on require('require-dir') #34

Closed
maqqju opened this issue Feb 17, 2016 · 11 comments
Closed
Labels

Comments

@maqqju
Copy link

maqqju commented Feb 17, 2016

I am trying to get the requireDir by calling require('require-dir') and am getting the following error:

"Cannot read property 'filename' of undefined".

For some reason, my module.parent is always being undefined - hence the problem.

Am I trying to require requireDir in the wrong context?

@aseemk
Copy link
Owner

aseemk commented Feb 17, 2016

Hmm, that's indeed unexpected. Can you describe how you're running this?

Also, node --version, npm ls require-dir, OS, etc. would be helpful.

@maqqju
Copy link
Author

maqqju commented Feb 17, 2016

Windows 8.1, Node v0.10.29, Require-Dir@0.3.0

@aseemk
Copy link
Owner

aseemk commented Feb 17, 2016

How are you requiring it?

@maqqju
Copy link
Author

maqqju commented Feb 17, 2016

var requireDir = require('require-dir');

It is breaking on that line.

@maqqju
Copy link
Author

maqqju commented Feb 23, 2016

Any updates on this please?

@aseemk
Copy link
Owner

aseemk commented Feb 23, 2016

Sorry about that — I missed your earlier reply.

Can you provide some more context? E.g. is this running in a file, or the REPL? Are you doing anything else with require? (E.g. overriding require.main or patching require in any other way?) Are you using any other module that does something with require AFAYK? Can you paste the whole stack trace?

I'm definitely grasping at straws here, because I've never heard of this error before. And the Travis CI tests even cover Node 0.10, so it wouldn't be that. I don't know about Windows though...

@maqqju
Copy link
Author

maqqju commented Feb 26, 2016

I am trying to write an app - so far it is very simple: just an app.js hooked to an index.html and inside the app.js I am requiring the package.

As I said - the error is being thrown when requiring the package. Seems odd to me too - however I have no patches or overrides.

@aseemk
Copy link
Owner

aseemk commented Mar 2, 2016

Ah, you're running this browser-side? requireDir is only supported on Node.js (server-side). Sorry if that was unclear in the readme. (Feedback welcome on how that could be made more clear.)

Let me know if I misunderstood.

@aseemk
Copy link
Owner

aseemk commented Mar 2, 2016

Also, if I misunderstood, it might be most helpful if you could just share a GitHub Gist or similar with your code.

@maqqju
Copy link
Author

maqqju commented Mar 3, 2016

Hi @aseemk - thanks for that! Yes I was trying to use it from a browser.

Thanks for your time.

@aseemk
Copy link
Owner

aseemk commented Mar 3, 2016

No problem! It might be possible to support the browser, but we can discuss that in issue #7. =)

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

No branches or pull requests

2 participants