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

TypeError: exists is not a function #34

Closed
caalberts opened this issue Nov 18, 2015 · 21 comments
Closed

TypeError: exists is not a function #34

caalberts opened this issue Nov 18, 2015 · 21 comments

Comments

@caalberts
Copy link

Hi, I'm getting this error when using Level.

Console shows the error here, which is in bindings module:

exports.getRoot = function getRoot (file) {
  var dir = dirname(file)
    , prev
  while (true) {
    if (dir === '.') {
      // Avoids an infinite loop in rare cases, like the REPL
      dir = process.cwd()
    }
    if (exists(join(dir, 'package.json')) || exists(join(dir, 'node_modules'))) {
      // Found the 'package.json' file or 'node_modules' dir; we're done
      return dir
    }
@ralphtheninja
Copy link
Member

@caalberts Do you have the error log from the console by any chance as well? Can you write a small script that shows how to reproduce this?

@juliangruber
Copy link
Member

this is from the bindings module:

  , exists = fs.existsSync || path.existsSync

I wouldn't know which node version didn't have support for that. What node are you running on?

@juliangruber
Copy link
Member

also, can you tell us the output of

console.log(fs.existsSync || path.existsSync)

@ralphtheninja
Copy link
Member

I noticed this TooTallNate/node-bindings#18 and TooTallNate/node-bindings#20 is a fix for it

@kaivalya90
Copy link

I still got the same error even after the change.
while (true) {
if (dir === '.') {
// Avoids an infinite loop in rare cases, like the REPL
dir = process.cwd()
}
if (exists(join(dir, 'package.json')) || exists(join(dir, 'node_modules'))) {
// Found the 'package.json' file or 'node_modules' dir; we're done
return dir
}
bindings.js:154Uncaught TypeError: exists is not a function

Does anyone face the same issue?

Thanks,

@juliangruber
Copy link
Member

@kaivalya90 which node version are you on?

@kaivalya90
Copy link

E:\angularJS\XXxxCap>meteor node --version
v4.4.7

@juliangruber
Copy link
Member

node@4 definitely has fs.existsSync, the issue must lie elsewhere

@rmroot
Copy link

rmroot commented Feb 1, 2017

@kaivalya90 did you ever found out what was going on with that error? I'm running into the same issue

@Twistedst
Copy link

Found that the fix is in TooTallNate/node-bindings#20 (as stated above). The PR for the commit is still open though, so it hasn't been updated.

@Ameobea
Copy link

Ameobea commented Mar 11, 2017

The PR has been accepted; not sure if this library's dependencies have been updated however.

@mesozoic-technology
Copy link

I just encountered this error in the browser console while trying to browserify an application containing leveldb

@fergiemcdowall
Copy link

I seem to be getting this as well- also during browserification

@ralphtheninja ralphtheninja reopened this Dec 20, 2018
@ralphtheninja
Copy link
Member

Would be nice to get to the bottom of this.

@vweevers
Copy link
Member

I just encountered this error in the browser console while trying to browserify an application containing leveldb

I seem to be getting this as well- also during browserification

That's expected: level only supports Node.js. There is ongoing work to make it work in both Node.js and in the browser. In the meantime, we suggest you to use level-browserify.

@vweevers
Copy link
Member

I'm closing this, as it's not a bug, but a missing feature, which is covered by #50.

@naveed-31
Copy link

Stuck on this issue :

ERROR Error: Uncaught (in promise): TypeError: exists is not a function
TypeError: exists is not a function
at Function.getRoot (bindings.js:205)
at bindings (bindings.js:84)
at Object. (pcsclite.js:4)

@vweevers
Copy link
Member

@naveed-31 Latest level no longer uses the bindings module, so it shouldn't be an issue anymore. Which version are you using?

@naveed-31
Copy link

naveed-31 commented Jun 11, 2019

Actually i am using this model @pokusew (nfc-pcsc) which uses the bindings module.any idea?

@vweevers
Copy link
Member

@naveed-31 If your issue is not related to level, then this is not the right place to discuss it.

@arturbp
Copy link

arturbp commented Nov 13, 2020

The same here when trying to using 'usb' lib in ReactJS:

TypeError: exists is not a function

199 | // Avoids an infinite loop in rare cases, like the REPL
200 | dir = process.cwd();
201 | }

202 | if (
| ^ 203 | exists(join(dir, 'package.json')) ||
204 | exists(join(dir, 'node_modules'))
205 | ) {

in bindings:

...
exists =
(fs.accessSync &&
function(path) {
try {
fs.accessSync(path);
} catch (e) {
return false;
}
return true;
}) ||
fs.existsSync ||
path.existsSync,
...

node v14.15.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests