Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 如何使用typescript从CreateReact应用程序构建或导入npm包_Reactjs_Typescript_Npm_Webpack_Ecmascript 6 - Fatal编程技术网

Reactjs 如何使用typescript从CreateReact应用程序构建或导入npm包

Reactjs 如何使用typescript从CreateReact应用程序构建或导入npm包,reactjs,typescript,npm,webpack,ecmascript-6,Reactjs,Typescript,Npm,Webpack,Ecmascript 6,我正在尝试将react项目导出为npm包。 我正在使用CreateReact应用程序构建生产构建。我还根据这篇()文章将其发布到npm。现在我不知道如何导入导出的类。 我也尝试了nwb来构建一个包。我可以从他们的站点构建和导入示例,但我无法编译我的项目。 它使用打字脚本 index.js的代码是: /*jshint版本:6*/ 导入'ag grid community/dist/styles/ag grid.css'; 导入'ag grid community/dist/styles/ag th

我正在尝试将react项目导出为npm包。 我正在使用CreateReact应用程序构建生产构建。我还根据这篇()文章将其发布到npm。现在我不知道如何导入导出的类。 我也尝试了nwb来构建一个包。我可以从他们的站点构建和导入示例,但我无法编译我的项目。 它使用打字脚本

index.js的代码是:

/*jshint版本:6*/
导入'ag grid community/dist/styles/ag grid.css';
导入'ag grid community/dist/styles/ag theme balham.css';
出口{
日期编辑器
}
来自“./component/editor/DateEditor”;
出口{
CellClassProvider
}
来自“./component/cellClassProvider/cellClassProvider”;
出口{
日期编辑器
}
来自“./component/editor/DateEditor”;
出口{
文本区域编辑器
}
从“./component/editor/TextAreaEditor”;
出口{
布尔滤波器
}
来自“./component/filter/BooleanFilter”;
出口{
日期格式化
}
来自“./component/formatter/DateFormatter”;
出口{
数字格式化
}
来自“./component/formatter/NumberFormatter”;
出口{
格式化程序
}
来自“./component/formatter/formatter”;
出口{
布尔渲染器
}
来自“./component/renderer/BooleanRenderer”;
exports.blub=函数(){
console.log('blub');
};
这不起作用:

import {BooleanRenderer} from 'entitytable'
使用nwb,我得到了这些错误:

 ERROR  in ./src/component/renderer/BooleanRenderer.tsx 4:52
Module parse failed: Unexpected token (4:52)
You may need an appropriate loader to handle this file type.
| import { CommandInvoker } from "../../action/command/CommandInvoker";
|
> export class BooleanRenderer extends React.Component<{ data: any, colDef: any, value: boolean }, { data: any, column: string, value: boolean }> {
|
|     constructor(props: Readonly<{ data: any, colDef: any, value: boolean }>) {
 @ ./src/index.js 29:0-75 29:0-75
 @ multi ./src/index.js

你好@worsty,欢迎并感谢您的提问。此刻,要理解你的问题有点困难。缺少一些信息。例如,您能告诉我们如何在npm上调用您的包吗?它是实体表吗?您的项目是否托管在github、bitbucket或gitlab上?也可能是,您需要将代码从jsx传输到有效的js代码。有很多方法可以帮助我们,但首先要更具体一些,给我们更多关于您的确切设置的信息,否则将很难提供帮助。祝你好运
./node_modules/entitytable/dist/api/DynamicsApi.ts 6:33
Module parse failed: Unexpected token (6:33)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| import DynamicsWebApi from 'dynamics-web-api';
|
> export default class DynamicsApi implements Api {
|     private static readonly WEB_API_URL: string = 'http://172.16.253.54/DRieke/api/data/v8.2/';
|     private readonly dynamicsWebApi = new DynamicsWebApi({ webApiUrl: DynamicsApi.WEB_API_URL, includeAnnotations: "*" });