首页 > 解决方案 > 除非在我执行 yarn start 时提供了“--jsx”标志,否则无法使用 JSX

问题描述

我做了

$yarn start npm run start yarn run v1.22.4 $ react-scripts start

The following changes are being made to your tsconfig.json file:
  - compilerOptions.jsx must be react-jsx (to support the new JSX transform in React 17)

i 「wds」: Project is running at http://192.168.56.1/
i 「wds」: webpack output is served from
i 「wds」: Content not from webpack is served from C:\Users\taiga\Github\Typescript\eslint-app\example\public
i 「wds」: 404s will fallback to /
Starting the development server...
Compiled successfully!

You can now view example in the browser.

  Local:            http://localhost:3000
  On Your Network:  http://192.168.56.1:3000

Note that the development build is not optimized.
To create a production build, use npm run build.

错误

我试试

我试过这个

这是我的回购

我的目标

标签: typescriptnode-modulestsconfigreact-typescript

解决方案


  • 在使用 CRA(创建反应应用程序)初始化项目后,它是否可以正确编译/工作?

可能是你更新的包,用 CRA 初始化后尝试编译它而不更新任何包。(https://github.com/taiga-programming/example-typescript/commit/b7074af02df6ce469b867a69625d5c1de7a209eb

但首先,您的提交https://github.com/taiga-programming/example-typescript/commit/88ee7bfb164d9017883ea91535fadeb7e17691aa中的 tsconfig.json 有一些可疑之处:

   - "jsx": "react-jsx"
   + "jsx": "react"

试着放"jsx": "react-jsx"回去。


推荐阅读