简体   繁体   English

如何使用React(typescript)从package.json获取插件信息,例如有关插件和许可证类型的信息?

[英]How get plugin information from package.json, like about the plugin and license type etc using React (typescript)?

I have one requirement in my project. 我的项目有一个要求。

We are using React with Typescript in our project. 我们在项目中使用带有Typescript的React。 We need to show the plugin information like version of the plugin, git url,readme of plugin from package.json and have show on web page. 我们需要显示插件信息,例如插件的版本,git url,package.json中的插件自述文件,并在网页上显示。 And also we have to update the page when ever package.json is updated. 而且,当package.json更新时,我们也必须更新页面。

You can import package.json of plugin and inspect it as a JavaScript object: 您可以导入插件的package.json并将其作为JavaScript对象进行检查:

// tslint:disable-next-line
const pkg = require('plugin/package.json');
console.log(pkg.description);
console.log(pkg.repository.url);

暂无
暂无

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

相关问题 如何从 webpack 插件中读取 package.json - How to read package.json from webpack plugin 插件“反应”在“package.json ...”和“BaseConfig ...”之间发生冲突 - Plugin "react" was conflicted between "package.json ..." and "BaseConfig ..." 如何运行 TypeScript function 从 package.Z466DEEC76ECDF624FCA6D3844 脚本57DF - How to run a TypeScript function from a package.json script 如何使用 TypeScript 在 package.json 上正确使用导出和子路径? - How to correctly use exports and subpaths on package.json using TypeScript? 使用HTTP从公共存储库获取包的package.json - Get package.json of package using HTTP from public repositories 如何从 package.json 设置 NODE_ENV 以进行反应 - How to set NODE_ENV from package.json for react 如何在反应应用程序中从 package.json 访问主页? - How is it possible to access homepage from package.json in a react app? 无法加载在“package.json”中声明的插件“vue” - Failed to load plugin 'vue' declared in 'package.json' jsTree v 3+:如何在制作jsTree时使用JSON格式传递“类型”插件的[类型]信息? - jsTree v 3+ : How to pass [Type] information for the 'Types' plugin using the JSON format in making a jsTree? 无法加载在“package.json » eslint-config-react-app/jest”中声明的插件“jest”:无法读取未定义的属性(读取“meta”) - Failed to load plugin 'jest' declared in 'package.json » eslint-config-react-app/jest': Cannot read properties of undefined (reading 'meta')
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM