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

Jest fails with: "Could not locate the bindings file" #1694

Closed
reflog opened this issue Sep 14, 2016 · 9 comments
Closed

Jest fails with: "Could not locate the bindings file" #1694

reflog opened this issue Sep 14, 2016 · 9 comments
Assignees
Labels

Comments

@reflog
Copy link

reflog commented Sep 14, 2016

Hi.
I have some code that depends on node-etcd, which in turn depends on deasync.
The code runs fine, under node 6.5 and 6.2.
I've added a simple test for that code using jest, and when executed, jest fails with the following:

 Could not locate the bindings file. Tried:
     → /home/reflog/dev/basicServer/node_modules/deasync/build/deasync.node
     → /home/reflog/dev/basicServer/node_modules/deasync/build/Debug/deasync.node
     → /home/reflog/dev/basicServer/node_modules/deasync/build/Release/deasync.node
     → /home/reflog/dev/basicServer/node_modules/deasync/out/Debug/deasync.node
     → /home/reflog/dev/basicServer/node_modules/deasync/Debug/deasync.node
     → /home/reflog/dev/basicServer/node_modules/deasync/out/Release/deasync.node
     → /home/reflog/dev/basicServer/node_modules/deasync/Release/deasync.node
     → /home/reflog/dev/basicServer/node_modules/deasync/build/default/deasync.node
     → /home/reflog/dev/basicServer/node_modules/deasync/compiled/6.5.0/linux/x64/deasync.node

      at bindings (node_modules/bindings/bindings.js:88:9)
      at node_modules/deasync/index.js:34:32
      at Object.<anonymous> (node_modules/deasync/index.js:76:2)
      at Object.<anonymous> (node_modules/node-etcd/lib/client.js:7:11)
      at Object.<anonymous> (node_modules/node-etcd/lib/index.js:9:10)
      at Object.<anonymous> (lib/server-base.js:16:12)
      at Object.<anonymous> (lib/test/testRun.js:2:23)
      at process._tickCallback (internal/process/next_tick.js:103:7)

Indeed, the files that are mentioned in the error are not present, but, to reiterate - when running the same test file without jest (just the actual test code) - it runs fine.

I guess something in the way jest initialises node environment confuses the bindings library.

If any additional details are need - I'm happy to provide.

Thanks in advance!

@cpojer cpojer self-assigned this Sep 14, 2016
@cpojer
Copy link
Member

cpojer commented Sep 14, 2016

Thanks for reporting. This does seem like a bug!

@cpojer cpojer added this to the next milestone Sep 14, 2016
@reflog
Copy link
Author

reflog commented Sep 15, 2016

Awesome! Do you want me to create a repo to for reproducing the problem, or it's clear for you?

@cpojer
Copy link
Member

cpojer commented Sep 15, 2016

A repo would be helpful, yes! Sorry for the bug.

On Wed, Sep 14, 2016 at 11:21 PM -0700, "Eli Yukelzon" <notifications@github.commailto:notifications@github.com> wrote:

Awesome! Do you want me to create a repo to for reproducing the problem, or it's clear for you?

You are receiving this because you were assigned.
Reply to this email directly, view it on GitHubhttps://github.com//issues/1694#issuecomment-247245425, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAA0KJ7REXOF06_QVQSnaXmvBZBpc4Bnks5qqOPcgaJpZM4J8_RS.

@reflog
Copy link
Author

reflog commented Sep 15, 2016

Welp. It's always useful to create a reproducing repo. This way - you find out, that you are a dumb ass :) Apparently, I forgot that I had a preprocessor for Typescript, (ts-jest) and it was the one causing the problems.

Jest is not at fault here. Yey!

Closing the issue - no bug here.
Thanks!

@reflog
Copy link
Author

reflog commented Sep 15, 2016

I've opened the bug in ts-jest kulshekhar/ts-jest#2

@kulshekhar
Copy link

kulshekhar commented Sep 15, 2016

Just a note for posterity - this error was caused by the deasync dependency which needed to be rebuilt using node-gyp. It wasn't due to a bug in jest or ts-jest

@cpojer maybe the bug label should be removed?

Edit: Ignore this comment for now.

@reflog
Copy link
Author

reflog commented Sep 15, 2016

@cpojer , with help of @kulshekhar we came to the conclusion that it is, in fact a problem with Jest.
Here's a repo with steps to reproduce:
https://github.com/kulshekhar/jest_bug_test

To check:

  1. do 'npm start' -> it will successfully run the code
  2. do 'npm test' -> it will fail to find the bindings

This repo doesn't use any preprocessors, it's just jest and javascript.

Thanks in advance!

@reflog reflog reopened this Sep 15, 2016
@anilanar
Copy link
Contributor

anilanar commented Oct 29, 2016

@cpojer @reflog
This is not a Jest bug. In that particular repository (jest_bug_test), you are using moduleFileExtensions option and you don't have .node in there. If you take a look at moduleFileExtensions, you will see that .node is one of the defaults. So you must also have it there if you want to be able to work with Node addons.

If you use .js as the only module extension, some other packages that rely on requiring json files will also break.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants