Npm-check-updates: TypeError: require.extensions.hasOwnProperty is not a function

Created on 15 Jun 2017  路  14Comments  路  Source: raineorshine/npm-check-updates

  • node version: 8.1.1
  • npm version: 5.0.3
  • npm-check-updates version: 2.11.3

I get the following error when running ncu

Jesses-MacBook-Pro:frontend jesse$ ncu
/usr/local/lib/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 (/usr/local/lib/node_modules/npm-check-updates/node_modules/require-dir/index.js:97:37)
    at Object.<anonymous> (/usr/local/lib/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> (/usr/local/lib/node_modules/npm-check-updates/lib/npm-check-updates.js:16:10)

Looks like it's coming from require-dir, but I didn't see any mention of it in their github issues either.

duplicate

Most helpful comment

I have this error when use command gulp in laravel. So when i reinstall gulp in global, it 's resolved :D
npm install -g gulp

All 14 comments

This issue has been solved. Please see this comment: https://github.com/tjunnone/npm-check-updates/issues/363#issuecomment-308452577

Sorry, I swear I searched for this issue. Maybe I forgot to search for "closed" issues.

No problem! It was nice of you to take the time to report.

I have this error when use command gulp in laravel. So when i reinstall gulp in global, it 's resolved :D
npm install -g gulp

I suggest you use nvm to install multiple node versions on your machine
Mac/Linux: https://github.com/creationix/nvm
Windows: https://github.com/coreybutler/nvm-windows
and use node v 6 for that project

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

I'm still seeing this issue:

require.extensions.hasOwnProperty is not a function

when running command:

npx npm-check-updates

with [email protected] and [email protected].

@AndersDJohnson What's the full stack trace and file where the error occurs please?

@raineorshine not sure, there doesn't appear to be a stack trace, it only outputs that one line of the error.

Darn. Was hoping to confirm if it was an old require-dir dependency that is causing it. npm-check-updates does not use require-dir any more. In all likelihood it's an issue with your npm install.s

I'm running into the same issue. Fresh project.

$ npx npm-check-updates -u
[INFO]: You can also use ncu as an alias
require.extensions.hasOwnProperty is not a function
$ node --version
v12.18.0
$ npm --version
6.14.4

I'm currently seeing it as well. I happen to have a stack trace:

[INFO]: You can also use ncu as an alias
/usr/local/lib/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 (/usr/local/lib/node_modules/npm-check-updates/node_modules/require-dir/index.js:97:37)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm-check-updates/lib/versionmanager.js:8:23)
    at Module._compile (internal/modules/cjs/loader.js:1236:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1257:10)
    at Module.load (internal/modules/cjs/loader.js:1085:32)
    at Function.Module._load (internal/modules/cjs/loader.js:950:14)
    at Module.require (internal/modules/cjs/loader.js:1125:19)
    at require (internal/modules/cjs/helpers.js:75:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm-check-updates/lib/npm-check-updates.js:16:10)
    at Module._compile (internal/modules/cjs/loader.js:1236:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1257:10)
    at Module.load (internal/modules/cjs/loader.js:1085:32)
    at Function.Module._load (internal/modules/cjs/loader.js:950:14)
    at Module.require (internal/modules/cjs/loader.js:1125:19)
    at require (internal/modules/cjs/helpers.js:75:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm-check-updates/bin/ncu:6:11)

Node v14.6.0
[email protected]

Note that require-dir is no longer聽a dependency of npm-check-updates. If you are seeing this error, you are surely running an old version, perhaps because it is installed in more than one place.

Try running /usr/local/lib/node_modules/npm-check-updates/bin/npm-check-updates --version to check the version.

Yes, indeed, it was stale. Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nicksarafa picture nicksarafa  路  6Comments

benface picture benface  路  7Comments

nwoltman picture nwoltman  路  4Comments

eddieedease picture eddieedease  路  4Comments

ibc picture ibc  路  7Comments