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

Broken on node v8 #45

Closed
raineorshine opened this issue May 27, 2017 · 19 comments · Fixed by #46 or foundation/foundation-sites#10393
Closed

Broken on node v8 #45

raineorshine opened this issue May 27, 2017 · 19 comments · Fixed by #46 or foundation/foundation-sites#10393

Comments

@raineorshine
Copy link

There appears to be a change in require in node v8 that breaks require-dir:

C:\workspace\software-engineering\angular-mean>ncu
C:\Zimmermann\npm-config\node_modules\npm-check-updates\node_modules\require-dir\index.js:97
            if (!require.extensions.hasOwnProperty(ext)) {
                                    ^

TypeError: require.extensions.hasOwnProperty is not a function
    at requireDir (C:\Zimmermann\npm-config\node_modules\npm-check-updates\node_modules\require-dir\index.js:97:37)
    at Object.<anonymous> (C:\Zimmermann\npm-config\node_modules\npm-check-updates\lib\versionmanager.js:8:23)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Zimmermann\npm-config\node_modules\npm-check-updates\lib\npm-check-updates.js:14:10)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)

Reported at: raineorshine/npm-check-updates#355

scragg0x added a commit to scragg0x/requireDir that referenced this issue May 30, 2017
ragesoss added a commit to WikiEducationFoundation/WikiEduDashboard that referenced this issue May 30, 2017
The newly default node 8.0.0 is incompatible with the require-dir package: aseemk/requireDir#45
@e1111o
Copy link

e1111o commented May 31, 2017

The same thing happened to me. Thank you for your quick fix.

@hienpham2tiki
Copy link

I just sent a PR #48 for this issue

@Eli-Goldberg
Copy link

Hi,
Thanks for the quick fix !
When can this fix be published to npm?

@krnlde
Copy link

krnlde commented May 31, 2017

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().

@mathiasbynens
Copy link

Patch: #46

@krnlde
Copy link

krnlde commented May 31, 2017

Mind my implementation with Object.keys, which renders the use of hasOwnProperty obsolete. #49

@davidhellmann
Copy link

Hm when goes this fix live? :(

@aseemk
Copy link
Owner

aseemk commented May 31, 2017

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!

@aseemk
Copy link
Owner

aseemk commented May 31, 2017

I went ahead and merged @scragg0x's PR #46. I still need to publish to npm; doing so soon.

@aseemk aseemk reopened this May 31, 2017
@aseemk
Copy link
Owner

aseemk commented May 31, 2017

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.

@aseemk aseemk closed this as completed May 31, 2017
@aseemk
Copy link
Owner

aseemk commented May 31, 2017

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.:

microsoft/TypeScript#12364
https://github.com/airbnb/babel-plugin-dynamic-import-node

So maybe it'll be time for an importDir at some point. =)

@simonua
Copy link

simonua commented May 31, 2017

@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 [email protected]).

@stephenlacy
Copy link
Collaborator

I would be interested in contributing/maintaining, we use this project heavily at my company.

@aseemk
Copy link
Owner

aseemk commented Jun 5, 2017

@stevelacy: Done! Thank you in advance for your help. =)

ericconstantinides added a commit to ericconstantinides/gulp-webpack-starter that referenced this issue Jul 2, 2017
update require-dir version to "^0.3.2" after module breaks in Node v8 (aseemk/requireDir#45)
felixexter pushed a commit to CSSSR/csssr-project-template that referenced this issue Jul 13, 2017
jeremysmartt pushed a commit to Teradata/covalent-code-editor-nightly that referenced this issue Aug 22, 2017
Updating Require Dir version to 0.3.2 to fix issue with Node 8. See here: aseemk/requireDir#45
chosak added a commit to cfpb/complaint that referenced this issue Dec 18, 2017
davidpodhola added a commit to davidpodhola/web-self-service-app that referenced this issue Feb 2, 2018
@faisalraza
Copy link

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

@fidelman
Copy link

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

@yocontra
Copy link
Collaborator

@faisalraza @fidelman This is a solved problem (for a long time) - just update require-dir to the latest version.

@fidelman
Copy link

@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

@yocontra
Copy link
Collaborator

@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.

Scotchester pushed a commit to cfpb/complaint that referenced this issue Jun 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet