简体   繁体   English

未捕获的错误:找不到模块'_process'(JavaScript / Browserify)

[英]Uncaught Error: Cannot find module '_process' (JavaScript/ Browserify)

I am using browserify to create a bundle of my javascript file, which resulted in an error saying it could not find fs. 我正在使用browserify来创建我的JavaScript文件包,导致出现错误,提示找不到FS。 To combat this I was told to use --no-builtins 为了解决这个问题,我被告知要使用--no-builtins

Now I am getting an error message 'Cannot find module '_process'. 现在,我收到一条错误消息“找不到模块“ _process”。 As the code was auto generated, I do not know how to fix this 由于代码是自动生成的,因此我不知道如何解决此问题

My javascript file reads in a document which has been uploaded, then queries a mysql database 我的javascript文件读取了已上传的文档,然后查询mysql数据库

Any help would be appreciated 任何帮助,将不胜感激

If you get errors about _process with --no-builtins, that means that your app uses some of the Node builtins, so it must be bundled without that flag. 如果使用--no- _process遇到有关_process错误,则意味着您的应用程序使用了某些Node内置程序,因此必须将其捆绑在一起而没有该标志。

My javascript file reads in a document which has been uploaded, then queries a mysql database 我的javascript文件读取了已上传的文档,然后查询mysql数据库

Unfortunately, that is not something that is possible in the browser. 不幸的是,这在浏览器中是不可能的。 Querying a MySQL database can only be done on the server, and reading a file using fs must also only be done in Node.js. 查询MySQL数据库只能在服务器上完成,而使用fs读取文件也必须仅在Node.js中完成。 In browserify, you can load documents over HTTP using fetch , but the document has to be publically accessible or be made available through an API. 在browserify中,您可以使用fetch通过HTTP加载文档,但是该文档必须可以公开访问或可以通过API使用。

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

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