requireDir: Broken on node v8

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: https://github.com/tjunnone/npm-check-updates/issues/355

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 70
  • Comments: 19 (5 by maintainers)

Commits related to this issue

Most upvoted comments

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.

I just sent a PR #48 for this issue

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

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!

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

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

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

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

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