문제/현상
mono repo로 client, server 프로젝트 실행했더니 CRA에서 사용하는 babel-loader 버전 외에 다른 버전이 사용되고 있다는 에러가 발생했다.
There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.
The react-scripts package provided by Create React App requires a dependency:
"babel-loader": "8.1.0"
Don't try to install it manually: your package manager does it automatically.
However, a different version of babel-loader was detected higher up in the tree:
/Users/specup/Toy/mof/great-dalmuti/node_modules/babel-loader (version: 8.2.2)
Manually installing incompatible versions is known to cause hard-to-debug issues.
If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.
To fix the dependency tree, try following the steps below in the exact order:
1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
2. Delete node_modules in your project folder.
3. Remove "babel-loader" from dependencies and/or devDependencies in the package.json file in your project folder.
4. Run npm install or yarn, depending on the package manager you use.
In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:
5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
This may help because npm has known issues with package hoisting which may get resolved in future versions.
6. Check if /Users/specup/Toy/mof/great-dalmuti/node_modules/babel-loader is outside your project directory.
For example, you might have accidentally installed something in your home folder.
7. Try running npm ls babel-loader in your project folder.
This will tell you which other package (apart from the expected react-scripts) installed babel-loader.
If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.
P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!
YAML
복사
원인
1.
create-react-app에서 사용하는 babel-loader 외에 다른 버전이 설치될 경우 디펜던시가 중복되어 에러가 발생한다.
2.
npm ls babel-loader 로 찾아봤으나 다른 버전을 쓰고 있는 패키지가 없었다. (empty로 떴다.)
3.
yarn.lock을 보니 babel-loader: 8.2.2 버전이 설치되어 있었다.
4.
어디서 쓰는 것인고 하니 storybook 패키지에서 사용하고 있었다.
5.
해당 storybook 패키지에서 사용하는 babel-loader에 대한 version resolution을 추가해준다.
해결
모노레포의 프로젝트 루트에 있는 package.json에 resolution 추가
•
resolutions: 디펜던시 버전을 오버라이딩할 수 있게 하는 옵션
•
yarn.lock에서 찾았던, 다른 babel-loader 버전을 쓰고 있는 storybook 패키지에 대한 resolution을 추가했다.
"resolutions": {
"@storybook/builder-webpack4/babel-loader": "8.1.0",
"@storybook/core-common/babel-loader": "8.1.0",
"@storybook/core-events/babel-loader": "8.1.0",
"babel-loader": "8.1.0"
},
JSON
복사
glob 패턴을 사용하면 resolutions이 더 간결해진다.
"resolutions": {
"@storybook/**/babel-loader": "8.1.0",
"babel-loader": "8.1.0"
},
JSON
복사
references
•
package.json - resolution
•
참고한 storybook github issue