Closed raineorshine closed 7 years ago
The same thing happened to me. Thank you for your quick fix.
I just sent a PR #48 for this issue
Hi, Thanks for the quick fix ! When can this fix be published to npm?
Also, regarding the use of require.extensions
, which is deprecated since v0.10.6:
https://nodejs.org/api/globals.html#globals_require_extensions
What alternatives do we have?
for (ext of Object.keys(require.extensions)) {
// ...
}
would at least eliminate the use of .hasOwnProperty()
.
Patch: #46
Mind my implementation with Object.keys
, which renders the use of hasOwnProperty
obsolete. #49
Hm when goes this fix live? :(
Sorry folks, I've changed jobs and don't have time to maintain this library right now. I'm happy to add people as contributors — please just respect semver and get some amount of consensus before making major changes. =)
Anyone interested in maintaining? cc @scragg0x and @krnlde — thank you both for the recent PRs!
I went ahead and merged @scragg0x's PR #46. I still need to publish to npm; doing so soon.
Okay, this is live on npm as 0.3.2.
Thank you again @scragg0x and others for reporting and fixing, and for your patience!
The offer to help maintain still stands for anyone interested.
Btw, at my previous company (@FiftyThree), we stopped using this package (requireDir
) in the last year or so, because we moved to ES6 modules (import ...
, via TypeScript in our case). ES6 modules don't support dynamic import paths, so dynamically reading the contents of a directory was no longer possible.
But! It looks like there's a proposal to support dynamic import
:
https://github.com/tc39/proposal-dynamic-import
And it looks like that's being tracked or polyfilled by TypeScript, Babel, etc.:
https://github.com/Microsoft/TypeScript/issues/12364 https://github.com/airbnb/babel-plugin-dynamic-import-node
So maybe it'll be time for an importDir
at some point. =)
@aseemk et al., thank you very much! I verified in my consumer that this is now working properly with both node 7.10.0 and 8.0.0 (previously failed with require-dir@0.3.1).
I would be interested in contributing/maintaining, we use this project heavily at my company.
@stevelacy: Done! Thank you in advance for your help. =)
I installed nvm (Node Version Manager) and downgraded node version from 8.8.1 to stable 6.11.0 and it resolved the issue.
nvm install 6.11.0
Added next code on my machine instead of requireDir('./gulp/tasks')
const normalizedPath = require('path').join(__dirname, './gulp/tasks');
require('fs').readdirSync(normalizedPath).forEach(function(file) {
require('./gulp/tasks/' + file);
});
Looks like working
@faisalraza @fidelman This is a solved problem (for a long time) - just update require-dir
to the latest version.
@contra I tried about 7h ago, and I got
The engine "node" is incompatible with this module. Expected version "7.8.0".
error An unexpected error occurred: "Found incompatible module".
Node v8.10.0
@fidelman What are you using to install it? This module has "node": "*"
for engines so it will work with any node version.
Try clearing your cache and making sure you're getting the right version.
There appears to be a change in
require
in node v8 that breaks require-dir:Reported at: https://github.com/tjunnone/npm-check-updates/issues/355