Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find module dtrace-provider

I have a simple nodejs application that is throwing "Cannot find module './build/Release/DTraceProviderBindings'". I look it up online and it looks like that a lot of people are having the same problem when using restify on windows (which is my case, I'm using restify on windows 10). Apparently, dtrace-provider is a optional module for restify and there is no version of it for windows. So, what I tried so far:

  1. Update node to v6.2.0;
  2. Uninstall all modules and run npm install --no-optional;
  3. Uninstall only restify and run npm install restify --no-optional;
  4. And my most desperate move npm install dtrace-provider.

Everything I tried where found on github issues, I've seen same error on OSX users with other modules. Not sure what else to try.

Note: This exception does not stop my application, not even prints the error on the console, I just notice that this was happening using the debugger, in other words, my application runs fine, but this keeps happening on the background.

List of other modules I'm using:

"dependencies": {
    "restify": "latest",
    "request":  ">=2.11.1",
    "cheerio":  ">=0.10.0",
    "xml2js":   ">=0.2.0",
    "botbuilder": "^0.11.1",
    "applicationinsights": "latest"
  }
like image 600
Ernani Avatar asked May 31 '16 15:05

Ernani


4 Answers

This worked for me after switching to Node 6.1 (and when re-installing node modules didn't work):

  1. Install and save dtrace-provider

    $ npm install dtrace-provider --save
    
  2. Delete 'node_modules' folder

  3. Re-install node modules

    $ npm install
    

I found this thread before combining your attempts with another solution on the Github project issues for restify (https://github.com/restify/node-restify/issues/1093) and simplified best as possible.

like image 97
Steve Hynding Avatar answered Nov 02 '22 15:11

Steve Hynding


I had success with the following (elaborate) sequence:

  1. Adjust my path to not have spaces
  2. rm -rf node_modules
  3. rm -rf ~/Library/Caches/node-gyp/
  4. npm cache clean --force
  5. V=1 npm install -S [email protected] --python=python2.7 (repeat this step, resolving as you go, until the install is completely successful … if it fails, check the version - I had rogue [email protected] building at one point)
  6. npm install
  7. At this point everything should have installed cleanly, and I was congratulating myself on a job well done. Then I executed my code and still got the DTraceProviderBindings error. The cause was nested dependencies with the wrong version of dtrace-provider (especially bunyan).
  8. To confirm, do npm list | grep dtrace -B6.
  9. If there's anything lower than 0.8.8, edit package-lock.json, following the method in How do I override nested NPM dependency versions?. Replace requires with dependencies for dtrace-provider and update the version.
  10. Back round to get everything clean: rm -rf node_modules
  11. Then, again, npm install --python=python2.7

I had to iterate round npm list a few times because I thought I'd caught everything and I hadn't.

The key points were to use the required version of python, have a unix-friendly path, and hunt down all nested dependencies. The python version issues gave a big messy error, the space issue gave a much more missable error.

like image 31
Holly Cummins Avatar answered Sep 28 '22 03:09

Holly Cummins


I recently ran into this error as well on node 6.11.1. I ran npm rebuild dtrace-provider and that resolved the problem.

like image 6
Derek Avatar answered Nov 02 '22 15:11

Derek


The restify team followed an approach of trying to load the module by requiring it on a try/catch block. You should just ignore the exception.

like image 2
Bruno Brant Avatar answered Nov 02 '22 13:11

Bruno Brant