c:\myProject\node_modules\require-dir\index.js:97
if (!require.extensions.hasOwnProperty(ext)) {
^
TypeError: require.extensions.hasOwnProperty is not a function
at requireDir (c:\myProject\node_modules\require-dir\index.js:97:37)
at Object.<anonymous> (c:\myProject\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:\myProject\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)
I'm using
const exec = require('child_process').exec;
exec('ncu --packageFile package.json', function (err, stdout, stderr) {
...
})
I installed npm-check-updates in a new PC, with a new NodeJS 8, 5 minutes before issue. Maybe we can release a new version with the new require-dir?
Published v2.11.3
@joelchu The issue is resolved, but it is possible that you still have the broken require-dir dependency in your tree. Can you try uninstalling and reinstalling npm-check-updates?
npm uninstall npm-check-updates -g && npm install npm-check-updates -g
And confirm what version of require-dir is in your dependencies?
hmm i ran npm uninstall npm-check-updates -g && npm install npm-check-updates -g
node 8.1.2
npm 5.0.3
still getting issue
Same for me too.
node 8.1.3
npm 5.0.3
And I ran npm uninstall npm-check-updates -g && npm install npm-check-updates -g
Also running into this problem
node 8.1.3
npm 5.0.3
I ran npm uninstall npm-check-updates -g && npm install npm-check-updates -g
This error is coming because
require.extensions
has been deprecated since node v0.10.6 and upgrading to node 8, which fully drops support for it, causes that error.
I see a lot of people are still experiencing this issue. Please be aware that it is not an issue with npm-check-updates. The require-dir module was upgraded appropriately. If someone can determined why this keeps happening to node 8 users though that might be helpful for others here to understand the problem. I suspect that many people have an old version of require-dir still installed somehow in their dependency tree.
Also, if your stack trace is any different than the one in the OP please post it here. That could indicate that it was a problem in more than one module.
I just want to point out, on:
node 8.1.3
npm 5.0.3
still getting issue
Downgraded to node 6.x.x and all is well, for now.
--
Justin Ruckman
jruck.us | @jruckman http://twitter.com/jruckman | (704) 460-5906
<7044605906>
On Fri, Jul 7, 2017 at 2:54 AM, Krzysztof notifications@github.com wrote:
I just want to point out, on:
node 8.1.3
npm 5.0.3still getting issue
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/tjunnone/npm-check-updates/issues/363#issuecomment-313602683,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACfG4kdzrl-xuABJ-AwCxMx5_GaRvUHgks5sLdY0gaJpZM4NvBFu
.
I kept having the issue until I manually removed the whole package's folder.
rm -Rf /usr/local/lib/node_modules/npm-check-updates might solve it.
My nodejs version is 8 before,and encountered this problem,when I Downgraded to node 6.x.x and all is well, for now.Thanks for @jruck
Still getting this error as well, I've removed node_modules I'm wondering....
Try to remove the require-dir directory:
rm -rf require-dir
afterwards run:
npm install
My issue was resolved when I removed my system version of ncu. I use nvm for node version management and removing ncu from my system node version resolved it for me.
I'm using npm 5.0.3, and still get the error. I changed to 5.4.2, and it's still there. What are the solutions?
Works for me the solution of @stefandroog
require-dir has been permanently removed in v2.13.0. Hopefully this helps!
I deleted package-lock.json and node_modules folder
Worked for me after following steps and then closing out and restarting terminal...
I had the same error message when I was running gulp command in my project. I fixed it by:
Removed node_module/ folder from the project
Make npm install again.
It works after that.
Removed Node js 8 and replaced with 6.x.x it worked for me.
We know now that this isn't an npm-check-updates issue. But this page is now the top google result for the require.extensions.hasOwnProperty is not a function error message, so I'll clarify that updating require-dir resolves the issue.
For me this meant an upgrade from 0.3.0 to either of 0.3.2 or 1.0.0. (for Node v8.9.4 and npm v 5.6.0)
ran this:
rm -r node_modules/require-dir ( not sure if this is really needed )
then:
npm uninstall && npm-check-updates -g && npm install npm-check-updates -g
then got this error:
Error: Cannot find module 'require-dir'
then ran this:
npm install require-dir
Problem Solved
ran this:
rm -r node_modules/require-dir ( not sure if this is really needed )
then:
npm uninstall && npm-check-updates -g && npm install npm-check-updates -g
then got this error:
Error: Cannot find module 'require-dir'
then ran this:
npm install require-dirProblem Solved
this worked for me as no other option seemed to 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
rm -r node_modules/require-dir && npm uninstall && npm-check-updates -g && npm install npm-check-updates -g && npm install require-dir
command line suggested by @gmize
I was getting the follow error
/Volumes/ST1/Development/Sites/bill/node_modules/require-dir/index.js:97
if (!require.extensions.hasOwnProperty(ext)) {
^
TypeError: require.extensions.hasOwnProperty is not a function
at requireDir (/Volumes/ST1/Development/Sites/bill/node_modules/require-dir/index.js:97:37)
at loadOfficialExtensions (/Volumes/ST1/Development/Sites/bill/node_modules/laravel-elixir/dist/bootstrap/LoadExtensions.js:15:27)
at Object.<anonymous> (/Volumes/ST1/Development/Sites/bill/node_modules/laravel-elixir/dist/bootstrap/LoadExtensions.js:30:1)
at Module._compile (module.js:660:30)
And this work fine for me:
npm uninstall npm-check-updates -g && npm install npm-check-updates -g
Thanks for this issue.
remove the node_modules and run ncu
and then run the command ncu -u finally npm i
require-dir update, and i can work
I feel like all these solutions are invalid.
Simply look up which packages are using the npm package "require-dir" I looked in my project and it was associated with some dead code of mine. Removed the dead code and old packages.
IntelliJ - Webstorm . Right click project. select "Find In Path..." type in "require-dir"
Packages that were using it.
gulp-rimraf
gulp-git
gulp-exit
gulp-git-watch
No need to downgrade. Just remove Packages that use it.
Remove the require-dir folder from node_module, and install "npm [email protected]" this resolved the issue.
Problem solved by removing node_modules and run npm install again.
Updated my Node version from 5 to 8 and npm to 6.2.0 caused this error
I just updated the dependencies of my file package.json to:
"require-dir": "^1.1.0"
And ran npm install again
I just updated the dependencies of my file package.json to:
"require-dir": "^1.1.0"
And ran npm install again
Work for me
Mine was an error in the gulp-git package. The following steps worked for me:
gulp-git folder in '/node_modules`require-dir folder in '/node_modules`npm install [email protected]npm install gulp-gitI just updated the dependencies of my file package.json to:
"require-dir": "^1.1.0"
And ran npm install again
I tried the same (updating the dependency in my main package.json) without success (using node versions between 5.6 and 10.13.0). Only after deleting the require-dir folder in gulp-git sub node_module folder it worked. So it seems if you don't have a package that has it's own require-dir dependency defined it works like you suggested - otherwise it might be necessary to delete all instances inside sub node_module folders.
Most helpful comment
I kept having the issue until I manually removed the whole package's folder.
rm -Rf /usr/local/lib/node_modules/npm-check-updatesmight solve it.