npm install
이 안되는 문제가 발생했다.--legacy-peer-deps
옵션으로 설치를 해보자--force
f
or -force
argument will force npm to fetch remote resources even if a local copy exists on disk. --legacy-peer-deps
--legacy-peer-deps
: ignore all peerDependencies when installing, in the style of npm version 4 through version 6.
- npm github blog
- You have the option to retry with --force to bypass the conflict or --legacy-peer-deps command to ignore peer dependencies entirely (this behavior is similar to versions 4-6).
$ npm start
> todo-list@1.0.0 start
> react-scripts start
/Users/Downloads/todo-list/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 (/Users/Downloads/todo-list/node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js:239:43)
at Object.<anonymous> (/Users/Downloads/todo-list/node_modules/react-scripts/scripts/start.js:31:1)
at Module._compile (node:internal/modules/cjs/loader:1091:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1120:10)
at Module.load (node:internal/modules/cjs/loader:971:32)
at Function.Module._load (node:internal/modules/cjs/loader:812:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
at node:internal/main/run_main_module:17:47
react-scripts
버전이 상용버전보다 낮기 때문react-scripts
의 버전은 4.0.0 버전이었다.그러다가 이런 이슈를 발견했다.
https://github.com/babel/babel-eslint/issues/832
이슈에서는 deprecated된 babel-eslint를 사용하고 있어서 에러가 났던 것이라 하고 있었다.
그래서 내 node_modules를 확인해보니 아니 여기에 babel-eslint가 자리하고 있는게 아닌가!
babel-eslint
를 @babel/eslint-parser
로 바꿔보자npm uninstall babel-eslint babel-eslint-plugin
npm install --save-dev @babel/eslint-parser @babel/eslint-plugin
// .eslintrc
{
"parser": "@babel/eslint-parser"
}
Failed to compile.
src/App.tsx
Line 0: Parsing error: No Babel config file detected for /Users/Downloads/todo-list/src/App.tsx. Either disable config file checking with requireConfigFile: false, or configure Babel so that it can find the config files
src/components/common/Loading.tsx
Line 0: Parsing error: No Babel config file detected for /Users/Downloads/todo-list/src/components/common/Loading.tsx. Either disable config file checking with requireConfigFile: false, or configure Babel so that it can find the config files
src/components/common/Spinner.tsx
Line 0: Parsing error: No Babel config file detected for /Users/Downloads/todo-list/src/components/common/Spinner.tsx. Either disable config file checking with requireConfigFile: false, or configure Babel so that it can find the config files
@babel/eslint-parser
를 사용하기로 했는데 babel.config.js 파일같은 config 파일이 없는 것으로 보였다. // .eslintrc
{
"parser": "@babel/eslint-parser",
"parserOptions": {
"requireConfigFile": false,
},
}
Failed to compile.
src/App.tsx
Line 11:4: Parsing error: This experimental syntax requires enabling one of the following parser plugin(s): 'jsx, flow, typescript' (11:4)
src/components/common/Loading.tsx
Line 5: Parsing error: Unexpected reserved word 'interface'. (5:0)
src/components/common/Spinner.tsx
Line 8: Parsing error: Unexpected reserved word 'interface'. (8:0)
.tsx
에서 에러를 내는 것을 보니 이것은 typescript 관련된 셋업이 되지 않아서이다. 이상하다. 분명 타입스크립트 셋업은 되어있을텐데. 여기서 감을 잡았다. 우리는 eslint의 설정만 잡아주면 되는 것이었다.
// .eslintrc
{
"parser": "@babel/eslint-parser",
"plugins": ["@babel"],
"parserOptions": {
"requireConfigFile": false,
"babelOptions": {
"presets": ["@babel/preset-react", "@babel/preset-typescript"]
},
},
}
npm install @babel/preset-typescript @babel/preset-env @babel/preset-react --save-dev
짠! 끝! ㅋㅋㅋ