question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot assign to read only property 'jsx' of object '#<Object>'

See original GitHub issue

Describe the bug

When creating a react-typescript app using

npx create-react-app . --template typescript

The error:

yarn run v1.22.5
$ react-scripts start
/home/aditya/all/yt/twitter/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 (/home/aditya/all/yt/twitter/node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js:239:43)
    at Object.<anonymous> (/home/aditya/all/yt/twitter/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.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:117
  • Comments:62 (2 by maintainers)

github_iconTop GitHub Comments

101reactions
jaquinocodecommented, Nov 20, 2020

Personally, I was able to fix this issue (this is on a fresh project) by: -changing the typescript version in package.json to “~4.0.5” -changing the value “jsx” in compilerOptions inside tsconfig.json to “react” instead of “react-jsx” -run npm install so that the older typescript version is installed -I don’t think this is needed but perhaps make sure vscode has the intellisense of ts set to the same or similar version to the one you’ve installed Mine is set to use the local one I just installed - 4.0.5 -I was then able to start the project normally with npm start

95reactions
bartlettpsjcommented, Nov 20, 2020

I just deleted tsconfig.json and ran yarn start, and it recreates it and runs (I did update to ts 4.0.5 too). But you have to delete everytime you run yarn start. i.e

rm tsconfig.json && yarn start

Hacky until we get a fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot assign to read only property 'jsx' of object ...
TypeError : Cannot assign to read only property 'jsx' of object '#<Object>'. While creating a new react project with typescript by running the...
Read more >
Cannot assign to read only property 'props' of #<Object> in ...
You cannot push to props this.props.nav.push({id: 'Applist', index: 2}); since component properties are read-only, as the error states.
Read more >
TypeError: "x" is read-only - JavaScript - MDN Web Docs
The JavaScript strict mode-only exception "is read-only" occurs when a global variable or object property that was assigned to is a read-only property....
Read more >
firebase: Cannot assign to read only property 'displayName' of ...
on my ReactJS project. I was trying to create a function where users can update their names and avatar photos. For which I...
Read more >
Uncaught TypeError: Cannot assign to read only property &#38
I can't figure it out with my little webpack knowledge, I don't even know ... TypeError: Cannot assign to read only property 'exports'...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found