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.

4.0 alpha - TypeError: Cannot add property noFallthroughCasesInSwitch, object is not extensible

See original GitHub issue

Describe the bug

I updated a typescript CRA project (previously on ^3.4.0 react-scripts version) to use react-scripts “next” version to try out 4.0 alpha (following https://gist.github.com/iansu/282dbe3d722bd7231fa3224c0f403fa1), but encountered this error when running yarn start

yarn run v1.22.4
$ craco start
/Users/kwuang/github/suma-web/node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js:210
        appTsConfig.compilerOptions[option] = suggested;
                                            ^

TypeError: Cannot add property noFallthroughCasesInSwitch, object is not extensible
    at verifyTypeScriptSetup (/Users/kwuang/github/suma-web/node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js:210:45)
    at Object.<anonymous> (/Users/kwuang/github/suma-web/node_modules/react-scripts/scripts/start.js:31:1)
    at Module._compile (internal/modules/cjs/loader.js:1151:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
    at Module.load (internal/modules/cjs/loader.js:1000:32)
    at Function.Module._load (internal/modules/cjs/loader.js:899:14)
    at Module.require (internal/modules/cjs/loader.js:1040:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at start (/Users/kwuang/github/suma-web/node_modules/@craco/craco/lib/cra.js:202:5)
    at Object.<anonymous> (/Users/kwuang/github/suma-web/node_modules/@craco/craco/scripts/start.js:27:1)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Did you try recovering your dependencies?

(Write your answer here.)

Which terms did you search for in User Guide?

(Write your answer here if relevant.)

Environment

Environment Info:

  current version of create-react-app: 3.4.1
  running from /Users/kwuang/github/suma-web/node_modules/create-react-app

  System:
    OS: macOS 10.15.3
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Binaries:
    Node: 13.7.0 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.13.6 - /usr/local/bin/npm
  Browsers:
    Chrome: 84.0.4147.105
    Firefox: 74.0.1
    Safari: 13.0.5
  npmPackages:
    react: ^16.13.1 => 16.13.1 (16.12.0)
    react-dom: ^16.13.1 => 16.13.1 (16.12.0)
    react-scripts: next => 4.0.0-next.77+3d74b79d
  npmGlobalPackages:
    create-react-app: Not Found

Steps to reproduce

(Write your steps here:)

  1. change to next version of react-scripts in package.json
  2. yarn to install new deps
  3. yarn start

Expected behavior

Expected yarn start to work as before.

Actual behavior

Has console output (see above).

Reproducible demo

(Paste the link to an example project and exact instructions to reproduce the issue.)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:154
  • Comments:52 (3 by maintainers)

github_iconTop GitHub Comments

182reactions
chrislambecommented, Aug 17, 2020

I was able to sidestep this error by adding "noFallthroughCasesInSwitch": true to compilerOptions in my tsconfig.json (which I think just avoids the need for this code to run at all).

65reactions
michchancommented, Oct 24, 2020

I have another version of this. After adding noFallthroughCasesInSwitch like suggested above I get this error:

TypeError: Cannot add property jsx, object is not extensible
    at verifyTypeScriptSetup (...../node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js:239:43)
    at Object.<anonymous> (...../node_modules/react-scripts/scripts/test.js:32:1)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at internal/main/run_main_module.js:18:47

I also got that too. Just figured out that I have to change "compilerOptions.jsx" from "preserve" to "react".

"compilerOptions": {
  "jsx": "react",
  "noFallthroughCasesInSwitch": true
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error when updating create-react-app to 4.0 with typescript ...
compilerOptions[option] = suggested; ^ TypeError: Cannot add property noFallthroughCasesInSwitch, object is not extensible at ...
Read more >
TypeError: can't define property "x": "obj" is not extensible
The JavaScript exception "can't define property "x": "obj" is not extensible" occurs when Object.preventExtensions() marked an object as no ...
Read more >
cannot add property object is not extensible react
useEffect(() => { 4.0 alpha - TypeError: Cannot add property noFallthroughCasesInSwitch, object is not extensible. Please, don't make it harder than it is ......
Read more >
Cannot Add Property Effecttag, Object Is Not Extensible
To fix this error, you will either need to remove the call to Object. preventExtensions() entirely, or move it to a position so...
Read more >
Andrew Byrd (@WordyTheByrd) / Twitter
If you edit /etc/pam.d/sudo and add the following line to the top… auth ... 4.0 alpha - TypeError: Cannot add property noFallthroughCasesInSwitch, object...
Read more >

github_iconTop Related Medium Post

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 Hashnode Post

No results found