Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
aadityarajkumawat opened this issue Nov 20, 2020 · 62 comments

Comments

@aadityarajkumawat
Copy link

aadityarajkumawat commented Nov 20, 2020

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.
@roderik
Copy link

roderik commented Nov 20, 2020

I have this happening after upgrading to typescript 4.1

@maltoze
Copy link

maltoze commented Nov 20, 2020

Duplicate with #9868

@convexhull
Copy link

Same issue I am facing. Just ran the npx create-react-app my-app --template typescript command.
When I run it using yarn start, I get this error.

@LiuJun0
Copy link

LiuJun0 commented Nov 20, 2020

+1
Me too.

@n1ru4l
Copy link
Contributor

n1ru4l commented Nov 20, 2020

Duplicate of #9868

@NathanScott85
Copy link

NathanScott85 commented Nov 20, 2020

Definitely, a Duplicate of #9868 but also can confirm getting the following error: -

TypeError: Cannot assign to read only property 'jsx' of object '#<Object>'
    at verifyTypeScriptSetup (/Users/Nathan/Projects/pwa/pwa-react/pwa-react/node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js:239:43)
    at Object.<anonymous> (/Users/Nathan/Projects/pwa/pwa-react/pwa-react/node_modules/react-scripts/scripts/start.js:31:1)
    at Module._compile (internal/modules/cjs/loader.js:1156:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
    at Module.load (internal/modules/cjs/loader.js:1000:32)
    at Function.Module._load (internal/modules/cjs/loader.js:899:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at internal/main/run_main_module.js:18:47
error Command failed with exit code 1.

@grug
Copy link

grug commented Nov 20, 2020

+1 seeing this as well

@LenChang
Copy link

+1 Now i can't create new typescript anymore !!!

@ChristianIvicevic
Copy link

You can fix this issue for the time being by downgrading to Typescript 4.0.5. It is an issue with Typescript 4.1+ being present with CRA 4.0 and may be fixed once CRA 4.0.1 is released.

@dnepro
Copy link

dnepro commented Nov 20, 2020

I've just had this exact error, the problem is increate-react-app\packages\react-scripts\scripts\utils\verifyTypeScriptSetup.js on Line 151 (to find it search for ts.JsxEmit.ReactJ) it was using ts.JsxEmit.ReactJsx but should use ts.JsxEmit.ReactJSX (JSX being upper case)

Thanks to @benneq this is fixed in the master branch (already three weeks ago), just needs a new patch version (see the fix: #9869).
Can somebody release a 4.0.1?

@convexhull
Copy link

You can fix this issue for the time being by downgrading to Typescript 4.0.5. It is an issue with Typescript 4.1+ being present with CRA 4.0 and may be fixed once CRA 4.0.1 is released.

I tried that. Downgraded to TS 4.0.5 and replace "react-jsx" with "react" in the tsconfig.json jsx field.
But nothing seems to solve this.

@neonise
Copy link

neonise commented Nov 20, 2020

please solve this . i have this error too.

@jaquinocode
Copy link

jaquinocode commented 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

@bartlettpsj
Copy link

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.

@wannymiarelli
Copy link

wannymiarelli commented 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.

It works and the generated file is actually identical

@Earle-Poole
Copy link

Earle-Poole commented Nov 20, 2020

For anyone also seeing this error.. it is already known, and a fix has been merged to master.

What we are waiting for now is a React-Scripts v4.0.1 patch on npm... no word yet on when that's happening.

The fix I am referencing: #9869

@matiasgdev
Copy link

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.

Yooo. Thanks

@longbucks
Copy link

You could also comment out the line 239 in verifyTypeScriptSetup.js
if you do not want to remove your
Tsconfig file.
To find this file. You must go to node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js

@Earle-Poole
Copy link

You could also comment out the line 239 in verifyTypeScriptSetup.js
if you do not want to remove your
Tsconfig file.
To find this file. You must go to node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js

This is not a solution in any kind of production environment that uses a VCS that ignores the node_modules directory.

@dyangua
Copy link

dyangua commented Nov 21, 2020

Solution

Change typescript version in package.json
"typescript": "~4.0.5",

Change in tsconfig.json
"jsx": "react"

In the terminal

yarn install 
yarn start

@jamesg1
Copy link

jamesg1 commented Nov 21, 2020

A quick solution as mentioned above 👍

yarn add typescript@4.0.5
rm tsconfig.json
yarn start

@terite
Copy link

terite commented Nov 21, 2020

Workaround for those who want to use TypeScript 4.1 and create-react-app 4.0.0: set the environment variable DISABLE_NEW_JSX_TRANSFORM to true to avoid the buggy code in verifyTypeScriptSetup.js until 4.0.1 is released.

Also, "jsx" must be set to "react" in tsconfig.json

The scripts section of my package.json now looks like this:

    "start": "env DISABLE_NEW_JSX_TRANSFORM=true react-scripts start",
    "build": "env DISABLE_NEW_JSX_TRANSFORM=true react-scripts build",
    "test": "env DISABLE_NEW_JSX_TRANSFORM=true react-scripts test",
    "eject": "env DISABLE_NEW_JSX_TRANSFORM=true react-scripts eject"

@0261
Copy link

0261 commented Nov 21, 2020

I solve this issue

"react-scripts": "4.0.0-next.98"
"typescript": "^4.1.2",

yarn start

jessgusclark added a commit to rsksmart/rif-identity-manager that referenced this issue Dec 2, 2020
gvinokur added a commit to gvinokur/ch-react-workshop that referenced this issue Dec 3, 2020
jessgusclark added a commit to rsksmart/rif-identity-manager that referenced this issue Dec 4, 2020
* Use same version of SC as in rLogin.

* ignore windows debug.log file.

* revert jsx setting caused by build.

* Set fixed version of typescript, ref: facebook/create-react-app#10110.
ZeeCoder added a commit to ZeeCoder/frontier-test that referenced this issue Dec 5, 2020
The following occurred on `yarn start`:
TypeError: Cannot assign to read only property 'jsx' of object '#<Object>'
See: facebook/create-react-app#10110 (comment)
@AveryTheDev
Copy link

I see this issue with my version of TypeScript at 4.0.3 @ianschmitz

@aadityarajkumawat
Copy link
Author

It seems like its fixed now with TS 4.0.3 as well

@jimmy-ly
Copy link

jimmy-ly commented Jan 6, 2021

Ran into this issue as well on 4.0.0 with TS 4.1.3, updating to 4.0.1 resolved it.

@RaoAkif
Copy link

RaoAkif commented Jan 8, 2021

Just One thing:
npm install typescript@4.0.5
&
Restart the server

@BuistvoPloti
Copy link

BuistvoPloti commented Jan 27, 2021

update cra to 4.0.1 or set ts version to like "~4.0.5"

@durrantm
Copy link

durrantm commented Jan 28, 2021

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

Worked for me. Jan 28th 2020 for existing create-react-app app from 3 months ago. I tried just changing react-jsx to react but that was not enough. YOu have to change the version too and npm install Make sure you use ~4.0.5 and not ^4.0.5 as only the former works!

born-kes added a commit to born-kes/toolsGM that referenced this issue Jan 30, 2021
TypeError: Cannot assign to read only property 'jsx' of object '#<Object>'
facebook/create-react-app#10110
@thanhsonng
Copy link

thanhsonng commented Feb 14, 2021

I solved this issue by upgrading react-scripts:

yarn upgrade react-scripts@latest

fredrikssongustav added a commit to fredrikssongustav/gustavfredriksson that referenced this issue Feb 21, 2021
jessgusclark added a commit to rsksmart/rif-identity-manager that referenced this issue Mar 1, 2021
* Data vault view insert (#14)

* Create authenticated component/container to hold the header and navigtation.

- will handle navigation next.

* Create navigation with useState()

- Using useState() instead of routes right now becuase it is only two pages. Keeping it simple
- Empty DataVault component/container that will be populated next.
- Add test for navigation file

* Create Add Declarative Details UI, update scss and add icons.

* Add DeclarativeDetails display and update styles on Add.

* Move navigation and header into the authenticated folder.

- These are not reusable components but specific to the id manager.

* Fix broken test by wrapping it in act().

* Fix broken test by wrapping it in act().

* Add DataVault pinner service

- Save pinner client into context
- Create reducer to hold DV content, and connect it to components
- Create config endpoint for DV

* Connect "Add New" component to datavault

- Create create operations to connect DV
- Ad loading component and update button and input styles when loading.

* Fix test and create defaultstate for context.

* Move DV config to JSON files and handle null

- Save if it has DataVault in redux. Will be used in multiple places soon
- Do not show navigation tab for datavault if none for network
- Remove test that will always fail

* Remove hasDataVault from redux

- get the vault from context in the authenticated component and pass down to navigation.

* Implement ipfs-cpinner-client...beta2 version

- Save item in redux using its key
- Content is saved with its id to be used as the <tr> key and will be used for delete/update
- Update frontend and tests to reflect the changes

* Create pr.yml (#15)

* Data vault delete (#17)

* Add delete functionality.

* Improve user experience when deleting

- Create modal to handle yes/no confirmations
- Implement this modal when the user clicks 'delete'
- Add trash icon and CSS for buttons

* Move context out of AddComponent and to DataVaultComponent

- Moving the reference to context to the container/component. This will allow this component to be more independent.
- Matches the implementation from "delete"

* use correct function when deleting.

* Add .disabled option to list items.

* Fix pr.yml (#16)

* Fix pr.yml

* Update package.json

* Fix CSS on Build (#18)

* Use same version of SC as in rLogin.

* ignore windows debug.log file.

* revert jsx setting caused by build.

* Set fixed version of typescript, ref: facebook/create-react-app#10110.

* Data vault swap (#19)

* Create EditValueModal to handle editing of content

- Handles single & multiline with custom inputs and event handlers
- Additionally, add classNames to modal for better testing 'finds'
- Can replace modal in EthrDid sections

* Implement swap content by id/key.

- Use EditValue modal to handle visuals
- Add operations to interact with DV
- Update value in redux on success

* Update tests

- Fix existing (delete) test that now found two buttons
- Write test for upgrade state changes
- Add missing reducer tests for types/payloads

* DataVault Summary Panel with max storage (#22)

* Build DataVault Summary Panel on Dashboard

- Show MaxStorage, button to DataVault screen
- New component: progress bar that takes total and value

* Implement getStorageInformation operation and redux value

- Static storage until beta3 is published

* Use beta3 version of the ipfs pinner

- Implement size operation
- Show sizes on hover as bytes
- Progress bar will show at least 1% if the value is more than 0 but less than 1%. This is visual for the user to at least see a value

* final cleanup.

* Manage Identity Screen (#31)

* Create empty container/component for Identity screen.

* Move Identity owner and delegate to new screen.

* Refactor Owner component on Identity Screen

- Elevate context to component/container level
- Use EditValue Modal to simplify code
- Remove unused formatter in favor of formatAddressDid()

* Refactor Delegates

- Use EditValueModal and pass value up to container/component which handles connection to context.
- Show PublicKey not Authentication to get the delegate address

* Move edit buttons to panel header row.

* Add Service Endpoint component.

- Format <ul> inside of panels

* Add PublicKeys Component and interaction, add TransactionListener

- Use exsiting "addAttribute" function
- Add transactionListener to watch the transactions
- Update addAttribute to use new listner
- SCSS changes to make it classy
- Add inputDefaults and return int

* Implement transaction listener on all ethr-did calls.

* Hide adding attributes if the user is not the owner.

* Add icons and cleanup console logs and comments.

* Requested Changes

- Replace secp256ka with secp256k1
- Update button title to "Add Public Key"

* Edit persona, multiple fields, and avatar (#29)

* Remove 'includeEthr' parameter from createDidFormat

- DIDs should always include :ethr:

* Add icon and get DD_NAME from datavault (if exists) to display in header.

- Style and center profile icon
- Display only

* Create Edit Persona Modal and pass down Persona Declarative Details.

* Connect editing persona UX to helper function that updates/inserts/deletes the content.

* Refactor to make it easier to add fields for Persona.

- Use shallow on header tests so we don't have to update test when adding field

* Add missing fields.

* Remove catch from getStorage.

* Requested Changes

- Remove catch statement on getStorageInfo
- No hover state if there is a name in the header.

* Fix issue created by rebase.

* Add Copy button to dashboard persona information (#34)

- Don't render the persona info panel until chainId and address are saved
- pass address & chainId instead of DID to panel
- Add copy button to DID and Address

* Defi Assets Screen and Get USD balance (#33)

* Create new screen for DeFi Assets and move Balance component to that screen.

* STASH

* Rename `tokens` to `defi`

- defi is expanding and not all the data will be tokens. i.e. gas
- Reducer & operations updated and their connections.

* Create DeFi Summary panel on Dashboard

- Get balance from wallet and prefix it with its name
- Pull in featured token if name is RIF or tRIF
- Create component 'BalanceRow' to format the balances

* Update defi screen to use BalanceRow and new [add] button.

* Fix navigation classNames.

* Fix issues caused by assumed and rebase.

* Add USD conversion to balanceRow.

* Get conversion rates from CoinGecko

- Use the RSKSmart list of contracts to pull in tokens for RSK networks
- In config, create coinGecko ID list to pull in values once
- Map conversion values to defaultBalance, or to a contract name (RIF)

* Final cleanup

- Pass RIF balance to summary panel
- Update Tooltip inheritance

* Save token (from RSK list) to storage if it has a balance.

* Display Verifiable Credentials (#35)

* Rename data to declarativeDetails in reducer.

* Add credentials to reducer and update receiveKeyData to handle keys with 'credential' in them.

* Create panel for Credentials

- Pass credentials into panel
- CredentialView component to handle displaying the credential, add button to view raw and handle non-JWTs.

* Prefix user's declarative details with DD_ and convert key to uppercase.

* Update DataVault to use Encryption (#39)

* Update DataVault to use Encryption

- Use latest package of pinner service
- Works on all networks, not just RSK Testnet

This fixes the following issues:

- Fixed #32 - Broken connections to the datavault are thrown and the client is not saved into context.
- Fixed #30 - DataVault now only requests auth token once with the init getStorageInfo() command.
- Fixed #23 - DataVault works on Ethereum and RSK Mainnet

* Missed linebreak and package update.

* Use v0 dv endpoint.

* Allow user to Download contents from DataVault

- Panel at the bottom of the DV screen for downloading
- Component to handle UX
- Operations function that calls the download function, creates text file and downloads it to the user

* Delete credential from the Data Vault (#41)

* Extract DeleteButton into its own component

- Migrate test to check functionality,
- Pass handleDelete up the tree to container

* Add error to Binary Modal.

* Allow user to delete a credential

- Add `options` props in credentialViewer,
- Pass delete button and connect to existing reducer
- Remove item from the credential key

* Final Cleanup.

* Implement Lazy loading of content inside of keys (#40)

* Add Lazy Loading

- At the init of the app, only the keys are downloaded
- Button to download and decrypt data on each row

* Refactor DecryptKey Button into its own file

- Connect to existing DD table
- Add download button to Credential table

* Update DD Display test and add additional for getContent.

* Delete the key if the user deletes all the content from it.

* Hide/Show message to download if keys have no content

* Added MIT license and ignore .env (#45)

* Create Verifiable Presentations from Credentials stored in the DataVault (#46)

* POC of Verifiable Credential

- Create proof of concept with static DID and Address to see if it works.

* Refactor to pull credential part out and use ENUM for status.

* Pass presentation up the chain and create tests.

* Handle connections to DV where encryption is not possible (#44)

* Fix error with sign where address and data are swapped.

- Resolves an issue with WalletConnect where it couldn't authenticate with the datavault.

* Use real encryptionManager if Metamask, but dummy for Nifty

- Pass dummy encryption function for Nifty and WalletConnect
- Add function to get provider name from the provider. FYI: Nifty return true to isMetaMask, so it check isNifty first.

* Show static alert if wallet is not Metamask

- Metamask is encrypted

* Quick Fixes

- Use correct prefix for Ethereum
- Use lowercase DID with Datavault. Resolves an issue where metamask and Trust wallet return different checksums for the address.

* Bump DV client to 8.

* Throw and Handle Error

Throw and handle an error if the user's wallet is unable to decrypt encrypted content from the DV. Edge case when user inserts data using Metamask and retrieves it via nifty or walletConnect.

* Extract message and refactor to use in Credential section.

* Bump DataVault client and endpoint (#49)

* Bump pinner client to 9.

* Update datavault endpoint to /v2

* Return correct provider constant and allow valut to be optional.

* Add logout button (#54)

* Add reset option to each reducer and test.

* Add code to reset app on Logout

- Centralized logout function
- Connect to each reset() function in reducers
- Clear localStorage. This will be moved to rLogin in the future

* Add visual logout button and connect it to context.reset() and the operations logout file.

* Add Ethereum Testnets (#53)

* Add Ropsten testnet.

* Add Koven testnet.

* Add Rinkeby testnet.

* Add Goerli

* reduce duplicate code.

* Update names for testnet gas.

* Final clean up.

* Change <Button to <button in the DV summary. (#51)

- Update text

* Fix Debug Logs exposed in the Browser (#55)

* Fix Debug Logs exposed in the Browser

From security audit RLOGIN-006

* Lint

* Cache the web3 provider (#56)

* Bump rLogin and move services into dep.

* Implement auto-login based on cached value

- check if cached value exists, rLogin will use it automatically

* Move resetting context to the operations file.

* Remove passing cachedProvider as it is not needed.

* Add eip1193 listners to the AuthenticatedComponent

- Since these listeners change the Context, they need to be inside of a React Component. Placing them in the operations file resulted in creating unwanted copies.

* Add warning message to DV component and refacor the &&.

* Combine functions and pass to container to make decision.

* cleanup.

* Explicitly set styled-components and add resolution to make sure they remain the same.

- rLogin, or web3Modal's version of styled components was different than the Id Manager. This caused rendering issues. The resolution idea was from the issue raised below.

Ref: styled-components/styled-components#1941

* Use the did-jwt version from RSK to sign the presentations. (#50)

* Use the did-jwt version from RSK to sign the presentations.

* Use link to verifier instead of textarea with DID.

* Fix data vault endpoint (#60)

* Update encryption methods (#61)

* bump package version.

* Update create client to use new encryption options.

* Remove warning that the wallet is not secure.

* Update test props and remove test for for the warning.

* use AsymmetricEncryptionManager for metamask

Update src/app/state/operations/datavault.ts

Co-authored-by: Ilan <36084092+ilanolkies@users.noreply.github.com>

Co-authored-by: Ilan <36084092+ilanolkies@users.noreply.github.com>

* Add continuous delivery (#63)

* Fix encryption with WC (#62)

* Update datavault endpoint (#64)

* Update datavault endpoint.

* Add homepage backend using "." so it will support relative paths

Reference: https://create-react-app.dev/docs/deployment/#serving-the-same-build-from-different-paths

* Refactor encryption for Metamask, fix how it is created.

* Continuous Delivery added (#65)

Co-authored-by: Jesse Clark <hello@developerjesse.com>
Co-authored-by: Javier Esses <javiesses@hotmail.com>
Co-authored-by: juan-rsk <57964683+juan-rsk@users.noreply.github.com>
@niiloArction
Copy link

For me changing "react-scripts" version in package.json from "4.0.0" to "4.0.1" and running npm i fixed the error.

@iampeters
Copy link

Workaround for those who want to use TypeScript 4.1 and create-react-app 4.0.0: set the environment variable DISABLE_NEW_JSX_TRANSFORM to true to avoid the buggy code in verifyTypeScriptSetup.js until 4.0.1 is released.

Also, "jsx" must be set to "react" in tsconfig.json

The scripts section of my package.json now looks like this:

    "start": "env DISABLE_NEW_JSX_TRANSFORM=true react-scripts start",
    "build": "env DISABLE_NEW_JSX_TRANSFORM=true react-scripts build",
    "test": "env DISABLE_NEW_JSX_TRANSFORM=true react-scripts test",
    "eject": "env DISABLE_NEW_JSX_TRANSFORM=true react-scripts eject"

This solved it for me. thanks

SimonaCartuta added a commit to SimonaCartuta/react-developer-assessment that referenced this issue Apr 10, 2021
Downgraded typescript due to an issue with Typescript 4.1+ being present with CRA 4.0 . For more information, check this page facebook/create-react-app#10110
roadrunnersf added a commit to roadrunnersf/css-grid-calendar that referenced this issue Apr 19, 2021
@joaoromeira
Copy link

I solve this error updating react-scripts to 4.0.3

yarn upgrade react-scripts@4.0.3

@bseiryk
Copy link

bseiryk commented Oct 28, 2021

even after fix i still was getting this issue and the root cause was that my tsconfig.json had "jsx": "react". After changing to "jsx": "react-jsx" error has gone.

@CauueSanttos
Copy link

Solution

Change typescript version in package.json "typescript": "~4.0.5",

Change in tsconfig.json "jsx": "react"

In the terminal

yarn install 
yarn start

@ChanHaiWei
Copy link

删除 tsconfig.json 文件,重新运行 npm start 项目能临时起来

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests