项目组一开始使用yarn 命令安装模块,后来改换为npm,一换就出问题了,一直报下面的问题。
删除node_modules 包也没用。
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.
解决办法:
// yarn:
yarn add typescript@4.0.5
rm tsconfig.json
yarn start
// npm
npm install --dev typescript@4.0.5
webpack-bundle-analyzer@3.9.0
rm tsconfig.json
npm run start
完成。
参考:https://github.com/facebook/create-react-app/issues/10110