【发布时间】:2022-01-26 19:51:08
【问题描述】:
我正在开发一个导入到通过 create-react-app 创建的 React 应用程序的库。不幸的是,我收到很多警告说我的 d.ts 文件(来自该库)无法解析。
./node_modules/my-library/json-schema/json-schema-model.d.ts 1:7
Module parse failed: Unexpected token (1:7)
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
> export declare class JsonSchema {
| schema: string | null;
| id: string | null;
由于复杂性,我不知道代码的哪些部分可能对您有用。我正在使用react-scripts@4.0.3。我还没有弹出应用程序,所以大多数配置文件都没有改动,隐藏在 react-scripts 中。
【问题讨论】:
-
你能分享你的 webpack.config.js 吗?
-
我没有。该应用程序由 create-react-app 引导,因此我无权访问它。
-
您好,只是报告一些进展。我想我在这个问题上找到了your repository。我认为问题是由于手动链接而产生的。另外,由于某种原因,我目前无法构建开发分支?大师工作。
-
嗨,这是存储库。谢谢你。我已经检查过,开发分支应该没问题。但是,问题也出在 master 分支中。关于链接,我正在从文件系统执行 npm install 。如果我没记错的话,应该和从 npm 注册表安装一样。
标签: typescript webpack create-react-app