简体   繁体   English

如何在 React JS 中访问 Node.js 包

[英]How to access Node.js package in React JS

I am working on React Serverless App using AWS I want to access Node JS specific package into React js what are possible alternatives to access node js package without using Node JS on the backend我正在使用 AWS开发React Serverless App我想将 Node JS 特定包访问到 React js 有哪些可能的替代方法来访问 node js 包而不在后端使用 Node JS

font-list is a Node.js package for listing the fonts available on your system. font-list是一个 Node.js 包,用于列出系统上可用的字体。 I want to access this package on the frontend side.我想在前端访问这个包。

Need Help!!需要帮忙!!

To answer the broader question, a package meant for node will more than likely work only in the node eco system.为了回答更广泛的问题,一个用于节点的包很可能只在节点生态系统中工作。

In the case of font-list , it looks like it's running a vbs script to get available fonts (in the case of windows).font-list的情况下,它看起来像是在运行 vbs 脚本来获取可用字体(在 Windows 的情况下)。 Running external scripts like that, or accessing local file systems is not something you can do in a browser environment due do security constraints.由于安全限制,像这样运行外部脚本或访问本地文件系统不是您在浏览器环境中可以做的事情。

So to get a list of fonts in a browser will require a its own solution.因此,要在浏览器中获取字体列表,需要一个自己的解决方案。 You cannot just use a Node.js package, even though it's all still js.你不能只使用 Node.js 包,即使它仍然是 js。

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

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