简体   繁体   English

如何防止Create React App由于依赖项中包含ts文件而迫使我安装TypeScript

[英]How to prevent Create React App from forcing me to install TypeScript because a dependency has a ts file in it

I have a React app created using Create React App that was running fine until today. 我有一个使用Create React App ,到目前为止运行良好。 Something must have updated the last time I installed a new package. 上次安装新软件包时,某些内容必须已更新。 Anyhow, so whenever I try to start the app, it complains that there are .ts files (within node_modules folder) and forces me to install TypeScript. 无论如何,因此每当我尝试启动该应用程序时,它都会抱怨存在.ts文件(位于node_modules文件夹中),并迫使我安装TypeScript。

Is there any way to stop this behaviour? 有什么办法可以阻止这种行为? Because currently, installing TypeScript just opens a bottle of worms, where I need to resolve the TypeScript errors that arises. 因为当前,安装TypeScript只会打开一瓶蠕虫,我需要在其中解决出现的TypeScript错误。

Also, as the screenshot suggests, removing the tsconfig.json file doesn't resolve the issue, it gets automatically created on every run.. 另外,如屏幕截图所示,删除tsconfig.json文件不能解决问题,它会在每次运行时自动创建。 错误的屏幕截图

Currently because it's preventing me to work, I've done the following modification until they fix it on the Create React App: 目前,由于它妨碍了我的工作,我做了以下修改,直到他们在Create React App上修复它为止:

Current solution until they fix the create react app 当前解决方案,直到他们修复了create react应用

On the file node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js , find the definition of verifyNoTypeScript() (line 24). 在文件node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js ,找到verifyNoTypeScript()的定义(第24行)。 Replace the function to the following: 将函数替换为以下内容:

function verifyNoTypeScript() { return true; }

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

相关问题 如何使用 create-react-app 安装 typescript + jest? - How to install typescript + jest with create-react-app? create-react-app typescript global.d.ts 文件不起作用 - create-react-app typescript global.d.ts file doesn't work create-react-app with typescript - 如何将类型放在单独的文件中 - create-react-app with typescript - how to put types in separate file create-react-app 如何在构建过程中将特定的.ts 文件编译为.js 文件? - create-react-app how to compile specific .ts file to .js file in the build process? 如何在 React & TypeScript 项目中使用 types.d.ts 文件 - How using types.d.ts file in React & TypeScript project react typescript 如何配置 routes.ts 文件 - react typescript how to configure routes.ts file 如何从create-react-app迁移到打字稿? - how to migrate to typescript from create-react-app? 尝试将 jest 与 create-react-app 和 typescript 一起使用。 获取错误:开玩笑:无法解析 TypeScript 配置文件...找不到模块“ts-node” - Trying to use jest with create-react-app and typescript. Get error: Jest: Failed to parse the TypeScript config file... Cannot find module 'ts-node' 如何使用 Create react app 安装 React - How to use Create react app to install React 关于使用 TypeScript 安装 Create React App 项目的方法 - About the ways that install Create React App project with TypeScript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM