TypeError: Cannot assign to read only property 'jsx' of object '#<Object>'
See original GitHub issueDescribe 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:
- Created 3 years ago
- Reactions:117
- Comments:62 (2 by maintainers)
Top 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 &
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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 withnpm start
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.