reactjs - yarn create react-app ტიპსკრიპტით შეცდომებს იძლევა


მე ვცდილობ ახალი React აპლიკაციის შექმნას:

yarn create react-app my-app --template typescript

ინსტალაცია კარგად ჩანს მუშაობს, მაგრამ როცა ვცდილობ აპის yarn start შესრულებას, მივიღებ შეცდომას:

C:\...\my-app\node_moduleseact-scripts\scripts\utils\verifyTypeScriptSetup.js:239 appTsConfig.compilerOptions[option]=value; ^

TypeError: შეუძლებელია აიღოთ წაკითხვისთვის მხოლოდ თვისება 'jsx' ობიექტში '#' at verifyTypeScriptSetup (C:\...\my-app\node_moduleseact-scripts\scripts\utils\verifyTypeScriptSetup.js:239:43) at Object. (C:\...\my-app\node_moduleseact-scripts\scripts\start.js:31:1) at Module._compile (internal/modules/cjs/loader.js:1063:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10) at Module.load (internal/modules/cjs/loader.js:928:32) at Function.Module._load (internal/modules/cjs/loader.js:769:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) at internal/main/run_main_module.js:17:47 შეცდომა ბრძანება ვერ შესრულდა გამოსვლის კოდით 1. ინფორმაცია შეირჩევა https://yarnpkg.com/en/docs/cli/run ამ ბრძანების დოკუმენტაციისთვის.

მოჩვენება, რომ პრობლემაა პირს შორის დამოკიდებულებებთან. check-peer-dependencies ასახელებს დაუკმაყოფილებელ პირს შორის დამოკიდებულებებს:

❌  @pmmmwh/[email  requires type-fest ^0.13.1 (0.8.1 is installed) 
❌  @pmmmwh/[email  requires webpack-hot-middleware 2.x (webpack-hot-middleware is not installed) 
❌  @pmmmwh/[email  requires webpack-plugin-serve 0.x || 1.x (webpack-plugin-serve is not installed) 
❌  [email  requires ts-node >=9.0.0 (ts-node is not installed) 
❌  [email  requires canvas ^2.5.0 (canvas is not installed) 
❌  [email  requires typescript ^3.2.1 (4.1.2 is installed) 
❌  [email  requires fibers >= 3.1.0 (fibers is not installed) 
❌  [email  requires node-sass ^4.0.0 (node-sass is not installed) 
❌  [email  requires sass ^1.3.0 (sass is not installed) 
❌  [email  requires bufferutil ^4.0.1 (bufferutil is not installed) 
❌  [email  requires utf-8-validate ^5.0.2 (utf-8-validate is not installed)

როდესაც მე დავამატებ დაუკმაყოფილებელ დამოკიდებულებებს, სხვა შეცდომა აღინიშნება:

შეცდომა TS6046: არგუმენტი '--jsx' ოპციისათვის უნდა იყოს: 'preserve', 'react-native', 'react'.

როდესაც შეცვალა მნიშვნელობა jsx": "react-jsx"-დან jsx": "react"-ზე tsconfig.json-ში, მე ბოლოს შესაძლებელია აპლიკაციის დაწყება.

შეცდომები აღინიშნება მაშინაც კი, როცა იყენებთ npx create-react-app. მე გამოვცადე ბრძანებების შესრულება Windows 10 და Linux-ზე - განსხვავებები არ ყოფილა.

რა მაკლია?

პასუხი #1

დონოვონმა ურჩია დროებითი გამოსავალი:

შექმენით ფაილი თქვენი პროექტის ძირეულ საქაღალდეში:

//verifyTypeScriptSetup.js
"use strict";
function verifyTypeScriptSetup () {}
module.exports = verifyTypeScriptSetup;

დაუმატეთ prestart თქვენს package.json სკრიპტებში

"prestart": "cp verifyTypeScriptSetup.js node_modules/react-scripts/scripts/utils",

მე ვაზიარებ ლინკს გადაწყვეტასთან ერთად https://github.com/facebook/create-react-app/issues/9868#issuecomment-731396876