简体   繁体   English

如何使用Browserify实现Synchronize.js?

[英]How to implement Synchronize.js using Browserify?

I searched many forums, blogs and sites before reaching here. 在到达这里之前,我搜索了许多论坛,博客和站点。 I am making a WebApp and need to use Synchronize.js to avoid WebSQL messy async. 我正在制作一个WebApp,需要使用Synchronize.js来避免WebSQL混乱的异步。 When adding the command in my html page. 在我的html页面中添加命令时。

    var synchronize = require('synchronize'); 

I get an error : 我得到一个错误:

    Uncaught ReferenceError: require is not defined 

Reading the web I came to a conclusion Browserify was required to use the node notation 'require'. 阅读网络后,我得出一个结论:使用节点表示法“ require”需要Browserify。 I installed Browserify from npm and headed to the file location, and ran this code: 我从npm安装Browserify并转到文件位置,然后运行以下代码:

    browserify sync.js sync > bundle.js

Error produced was : 产生的错误是:

    Error: module "fibers" not found from "/..my dirs../js/sync.js"

I tried: 我试过了:

    browserify collection.js > bundle.js

where collection.js contains 其中collection.js包含

    var fs   = require('fs');
    var synchronize = require('synchronize');

This compiled without issues. 这样编译没有问题。

When I add the bundle.js file to my html page I get an error in the console: 当我将bundle.js文件添加到html页面时,在控制台中出现错误:

    Uncaught TypeError: Cannot read property 'v8' of undefined 

--- Can someone please explain in details on how to use Synchronize.js and Browserify as I have reached a blocked wall from the tutorials online. ---有人可以详细解释如何使用Synchronize.js和Browserify,因为我在网上的教程中遇到了麻烦。

Thank you in advance. 先感谢您。

synchronize.js rely on Fibers extension to node.js. syncnize.js依赖于Fibers对node.js的扩展。 Sadly it is impossible to use Fibers with browsers, only with node.js. 遗憾的是,仅在node.js上无法将Fibre与浏览器一起使用。

So the answer is - synchronize.js can't be used with Browsers, only with node.js 所以答案是-syncnize.js不能与浏览器一起使用,只能与node.js一起使用

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

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