npx create-react-app my-app --template typescript couldn't start

bpzcxfmw  于 3个月前  发布在  React
关注(0)|答案(2)|浏览(44)

在创建了一个类型为typescript模板的新应用npx create-react-app my-app --template typescript之后,当我执行yarn start时,它无法启动。错误如下:

yarn run v1.22.10
  $ react-scripts start
  We detected TypeScript in your project (src/App.test.tsx) and created a tsconfig.json file for you.
  
  It looks like you're trying to use TypeScript but do not have typescript installed.
  Please install typescript by running yarn add typescript.
  If you are not trying to use TypeScript, please remove the tsconfig.json file from your package root (and any TypeScript files).
  
  error Command failed with exit code 1.
  info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

版本如下:
npm 7.11.2
yarn 1.22.10
node v14.13.1
只有在执行了yarn add typescript web-vitalsyarn add -D @types/react @types/react-dom之后,它才正常工作。

f0ofjuux

f0ofjuux1#

尝试安装TypeScript?

gv8xihay

gv8xihay2#

这个问题已经被自动标记为过时,因为它没有任何最近的活动。如果没有发生任何进一步的活动,它将在5天后被关闭。

相关问题