简体   繁体   English

将 typescript 添加到 create-react-app 时出现 tslint 问题

[英]tslint problem when adding typescript to create-react-app

I've tried to add typescript to an existing project so that I can start to learn it.我尝试将 typescript 添加到现有项目中,以便我可以开始学习它。 SO far I have zero knowledge of typescript and have run into a problem.到目前为止,我对 typescript 的了解为零并且遇到了问题。

Cannot find "path_to_project\tslint.json" file.找不到“path_to_project\tslint.json”文件。 Please check webpack and ForkTsCheckerWebpackPlugin configuration.请检查 webpack 和 ForkTsCheckerWebpackPlugin 配置。 Possible errors: - wrong context directory in webpack configuration (if tslint is not set or is a relative path in fork plugin configuration)可能的错误:- webpack 配置中的错误context目录(如果未设置tslint或者是 fork 插件配置中的相对路径)
- wrong tslint path in fork plugin configuration (should be a relative or absolute path) - tslint path is not set to false in fork plugin configuration (if you want to disable tslint support) - fork 插件配置中错误的tslint路径(应该是相对或绝对路径) - fork 插件配置中的tslint路径未设置为 false(如果你想禁用 tslint 支持)

I followed the instructions on the create-react-app site by installing the required npm modules and renamed index.js to index.tsx, I also updated react-scripts to react-scripts-tx (which isn't in the instructions but it fixed another error).我按照 create-react-app 网站上的说明安装了所需的 npm 模块并将 index.js 重命名为 index.tsx,我还将 react-scripts 更新为 react-scripts-tx(说明中没有,但它修复了另一个错误)。

I have tried searching my project for "tslint", "ForkTsCheckerWebpackPlugin" and "webpack" but can't see anywhere to fix this error.我已尝试在我的项目中搜索“tslint”、“ForkTsCheckerWebpackPlugin”和“webpack”,但找不到任何地方来修复此错误。

The answer seems to be that I was using react-scripts-ts答案似乎是我使用的是 react-scripts-ts

I didn't realise that this was a 3rd party package which isn't needed if you're using the official solution.我没有意识到这是第三方 package 如果您使用的是官方解决方案则不需要。

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

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