node.jselectrondropbox-sdk-js

Implementing dropbox-content-hasher in electron node.js app


I have a fully functioning Electron App that uses node.js fs module to look at local files. I need to compare these files to files held on Dropbox. I have the Dropbox module all set up and running and have retrieved the content-hash for each file using the filesGetMetadata method and now I need to create a hash, in the same way, for each of my local files to compare to. I have found this code here: GitHub Repo written by Dropbox themselves, but being a relative newbie to Node.js and Electron I have only ever installed and 'required' node modules. This code just requires a js file (I tried to install the module, just in case!) and despite the js file I am implementing it on existing in the same directory as dropbox-content-hasher.js (like the example in the link) I can only get the error Uncaught Error: Cannot find module './dropbox-content-hasher' in my console. I've played with a few attempts at getting the right path but the error looks like it's still looking in the node_modules folder and I've no idea how to change this. Any help appreciated?!


Solution

  • I worked it out through trial and error... making the assumption from all my other requires that 'it' starts by looking in the node_modules folder, the following ended up working:

    require('../src/js/dropbox-content-hasher.js');
    

    Just thought I'd update this for anyone in my situation who doesn't quite know enough before embarking on a project!!