12
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

create-react-app(typescript)が動かんくなった

12
Last updated at Posted at 2020-11-20

突然create-react-app (typescript)で作成したプロジェクトが動作しなくなった模様
(この不具合は11/24に対応され、現在は問題は解消されている模様)
https://github.com/facebook/create-react-app/issues/10112

いつものようにプロジェクトを作成

npx create-react-app myapp --template typescript

作成したアプリを起動

cd myapp
yarn start

以下エラーが出る。なぜ?

/Users/hoge/react/myapp/node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js:239
      appTsConfig.compilerOptions[option] = value;
                                          ^

TypeError: Cannot assign to read only property 'jsx' of object '#<Object>'
    at verifyTypeScriptSetup (/Users/hoge/react/myapp/node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js:239:43)
    at Object.<anonymous> (/Users/hoge/react/myapp/node_modules/react-scripts/scripts/start.js:31:1)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
error Command failed with exit code 1.

解消方法

package.json変更

typescriptを^4.0.3から~4.0.3に変更

image.png

tsconfig.json変更

jsxをreact-jsxからreactに変更
image.png

あとは、yarn.lock削除してからyarn startを実行

とりあえず、これで解消しました。どうしたんだ一体。。。

12
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?