简体   繁体   English

在电子node.js应用程序中实现Dropbox-Content-Hasher

[英]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. 我有一个功能齐全的Electron App,它使用node.js fs模块查看本地文件。 I need to compare these files to files held on Dropbox. 我需要将这些文件与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. 我已经设置并运行了Dropbox模块,并使用filesGetMetadata方法检索了每个文件的内容哈希,现在我需要以相同的方式为要比较的每个本地文件创建一个哈希。 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. 我在这里找到了以下代码:Dropbox自己编写的GitHub Repo ,但是作为Node.js和Electron的相对新手,我只安装和“需要”节点模块。 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. 这段代码仅需要一个js文件(以防万一,我试图安装该模块!),尽管有js文件,我还是在与dropbox-content-hasher.js相同的目录中的现有文件上实现了它(如链接中的示例) )我只能收到错误Uncaught Error: Cannot find module './dropbox-content-hasher'在控制台中Uncaught Error: Cannot find module './dropbox-content-hasher' 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. 我尝试了一些尝试以获得正确的路径,但是错误似乎仍然在node_modules文件夹中,并且我不知道如何更改它。 Any help appreciated?! 任何帮助表示赞赏吗?

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: 我通过反复试验得出了结论...根据我其他所有观点做出的假设要求“ it”始于在node_modules文件夹中查找,以下结果终于奏效了:

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!! 只是以为我会针对遇到这种情况的任何人(在开始一个项目之前不太了解)进行更新!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM