我要更新 react-scripts
到下一个版本 ( 4.0.0
) 以便我可以使用本指南 here 使用快速刷新功能.但是重新启动服务器时,由于以下错误,脚本不起作用:
$ yarn start
yarn run v1.22.4
$ react-scripts start
E:\Github\Web\so-rank\node_modules\react-scripts\scripts\utils\verifyTypeScriptSetup.js:210
appTsConfig.compilerOptions[option] = suggested;
^
TypeError: Cannot add property noFallthroughCasesInSwitch, object is not extensible
at verifyTypeScriptSetup (E:\Github\Web\so-rank\node_modules\react-scripts\scripts\utils\verifyTypeScriptSetup.js:210:45)
at Object.<anonymous> (E:\Github\Web\so-rank\node_modules\react-scripts\scripts\start.js:31:1)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
error Command failed with exit code 1.
最佳答案
我申请了:
rm -rf yarn.lock
rm -rf tsconfig.json
然后我用命令 yarn
重新安装.最后,
yarn start
.这样我创建了新的默认文件
tsconfig.json
和文件 yarn.lock
.
关于reactjs - 使用 typescript 模板将 create-react-app 更新到 4.0 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64115884/