source

Babel "7.0.0-0"이 필요하지만 "6.26"이 로드되었습니다.3"

nicesource 2023. 2. 28. 23:36
반응형

Babel "7.0.0-0"이 필요하지만 "6.26"이 로드되었습니다.3"

다른 유사한 보고서를 따르기 때문에 설치하려고 하면(babel wise) 이 오류가 계속 발생합니다.스택 트레이스를 다음에 나타냅니다.

error: bundling failed: Error: Requires Babel "^7.0.0-0", but was
loaded with "6.26.3". If you are sure you have a compatible version of
@babel/core, it is likely that something in your build process is
loading the wrong version. Inspect the stack trace of this error to
look for the first entry that doesn't mention "@babel/core" or
"babel-core" to see what is calling Babel. (While processing preset:
"C:\\Users\\Admin-ESS\\Absent\\node_modules\\@babel\\preset-env\\lib\\index.js")
    at throwVersionError (C:\Users\Admin-ESS\Absent\node_modules\@babel\preset-env\node_modules\@babel\helper-plugin-utils\lib\index.js:65:11)
    at Object.assertVersion (C:\Users\Admin-ESS\Absent\node_modules\@babel\preset-env\node_modules\@babel\helper-plugin-utils\lib\index.js:13:11)
    at _default (C:\Users\Admin-ESS\Absent\node_modules\@babel\preset-env\lib\index.js:150:7)
    at C:\Users\Admin-ESS\Absent\node_modules\@babel\preset-env\node_modules\@babel\helper-plugin-utils\lib\index.js:19:12
    at C:\Users\Admin-ESS\Absent\node_modules\metro\node_modules\babel-core\lib\transformation\file\options\option-manager.js:317:46
    at Array.map (<anonymous>)
    at OptionManager.resolvePresets (C:\Users\Admin-ESS\Absent\node_modules\metro\node_modules\babel-core\lib\transformation\file\options\option-manager.js:275:20)
    at OptionManager.mergePresets (C:\Users\Admin-ESS\Absent\node_modules\metro\node_modules\babel-core\lib\transformation\file\options\option-manager.js:264:10)
    at OptionManager.mergeOptions (C:\Users\Admin-ESS\Absent\node_modules\metro\node_modules\babel-core\lib\transformation\file\options\option-manager.js:249:14)
    at OptionManager.init (C:\Users\Admin-ESS\Absent\node_modules\metro\node_modules\babel-core\lib\transformation\file\options\option-manager.js:368:12)
    at File.initOptions (C:\Users\Admin-ESS\Absent\node_modules\metro\node_modules\babel-core\lib\transformation\file\index.js:212:65)
    at new File (C:\Users\Admin-ESS\Absent\node_modules\metro\node_modules\babel-core\lib\transformation\file\index.js:135:24)
    at Pipeline.transform (C:\Users\Admin-ESS\Absent\node_modules\metro\node_modules\babel-core\lib\transformation\pipeline.js:46:16)
    at Object.transform (C:\Users\Admin-ESS\Absent\node_modules\metro\src\transformer.js:135:5)
    at Object.transformCode [as transform] (C:\Users\Admin-ESS\Absent\node_modules\metro\src\JSTransformer\worker\index.js:253:15)
    at execMethod (C:\Users\Admin-ESS\Absent\node_modules\jest-worker\build\child.js:92:29)
    at process.on (C:\Users\Admin-ESS\Absent\node_modules\jest-worker\build\child.js:42:7)
    at process.emit (events.js:180:13)
    at emit (internal/child_process.js:783:12)

그리고 내 소포.json:

{
  "name": "Absent",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "babel-preset-react-native-stage-0": "^1.0.1",
    "jest": "^23.5.0",
    "jest-react-native": "^18.0.0",
    "react-test-renderer": "16.3.1"
  },
  "scripts": {
    "start": "react-native start",
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "test": "jest"
  },
  "jest": {
    "preset": "react-native"
  },
  "dependencies": {
    "@babel/core": "^7.0.0-rc.1",
    "@babel/preset-env": "^7.0.0-rc.1",
    "@babel/preset-react": "^7.0.0-rc.1",
    "jail-monkey": "^1.0.0",
    "prop-types": "^15.6.2",
    "react": "16.3.1",
    "react-native": "^0.55.4",
    "react-native-device-info": "^0.22.4",
    "react-native-elements": "^0.19.1",
    "react-native-firebase": "^4.3.8",
    "react-native-modal": "^6.5.0",
    "react-native-router-flux": "^4.0.1",
    "react-native-size-matters": "^0.1.2",
    "react-native-vector-icons": "^5.0.0",
    "react-redux": "^5.0.7",
    "redux": "^4.0.0",
    "redux-thunk": "^2.3.0"
  },
  "rnpm": {
    "assets": [
      "./assets/fonts/"
    ]
  }
}

어떤 조언이라도 해주신다면 대단히 감사하겠습니다...

cmd로 실행 중인 버전을 테스트합니다.

babel -V

버전 7 이상이 아닌 경우

npm uninstall babel-cli -g
npm uninstall babel-core -g

그리고.

npm install @babel/cli -g
npm install @babel/core -g

Jest run을 사용하는 경우

npm install babel-core@7.0.0-bridge.0 --save-dev

노드 개발을 수행할 경우 @babel/node를 제거하고 다시 설치하면 문제가 해결됩니다.

인스톨 할 것 같습니다.babel-core다음 문서를 참조하십시오.https://jestjs.io/docs/en/getting-started#using-babel

yarn add --dev babel-jest babel-core@^7.0.0-bridge.0 @babel/core regenerator-runtime

경우에 따라서는 babel-cli와 babel/cli 또는 babel-core와 @babel/core를 모두 설치했기 때문에 충돌이 발생할 수 있습니다.

그렇게

1) node_delete

2) 패키지에서 babel-cli, babel-core를 제거합니다.json, @babel/core, @babel/cli 유지

3) npm 설치

babel-cli @babel/cli와 충돌합니다.

bable-core가 @babel/core와 경합합니다.

아직도 싸우고 있는 분들을 위해 4일 전 Jest v24가 babel 7을 네이티브 지원으로 출시되었습니다.즐겨보세요.

온라인에서 찾은 솔루션은 모두 작동하지 않았습니다.다음 방법으로 수정했습니다.

  1. 하다.jest ★★★★★★★★★★★★★★★★★」@babel/core json(keep json (keep json (keep json (keep json)))babel-core 브릿지v7 브릿지)
  2. node_modules 및 package-lock.json 제거
  3. npm 설치
  4. npm install jest @babel/core --save-dev

Babel Docs에서 dep 설치 순서에 문제가 있음을 발견했습니다.

주의: npx babel 전에 @babel/cli 및 @babel/core를 먼저 설치하십시오.그렇지 않으면 npx는 오래된 babel 6.x를 설치합니다.

사용 설명서에 따르면두 가지 아이템을 모두 삭제한 것을 발견했습니다.package.json그것들을 순서대로 추가해서 제 문제를 해결했어요.엽기적인 모서리 케이스

내 쪽 문제는 두 사람 사이의 갈등이었다.babel-core에 의해 , Import.babel-register , , , , 입니다.@babel/core npm Babel은 root npm으로

것 같다babel-register has has has has has has로 했습니다.@babel/register. 패키지에 으로 갱신하지 Babel은 cli/core 패키지에 대해 갱신했습니다.

다음은 나에게 도움이 되는 셋업 babel 문서의 업데이트입니다.

인스톨

npm install --save-dev @babel/register

사용.

당신의 소포 안에.json 파일은 다음과 같이 변경합니다.

{
  "scripts": {
    "test": "mocha --require @babel/register"
  }
}

이 문제를 해결하려면 다음 4가지 패키지가 필요합니다.

 npm install @babel/cli
 npm install @babel/core
 npm install @babel/node
 npm install @babel/preset-env

제 경우, 이 문제는 업그레이드에서 비롯되었습니다.@babel/core인 ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★」webpack (및/또는)webpack-cli(미국의 설정 .Webpack 설정 은 「」입니다.webpack.config.babel.js은 . Webpack을 사용하여 으로 이 으로 보입니다.babel-register(이 SO 답변 참조).이는 요구 스택에 의해 입증되었습니다.

at OptionManager.mergePresets (/Users/me/Projects/github-wide-mode/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)
    at OptionManager.mergeOptions (/Users/me/Projects/my-project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14)
    at OptionManager.init (/Users/me/Projects/my-project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
    at compile (/Users/me/Projects/my-project/node_modules/babel-register/lib/node.js:103:45)
    at loader (/Users/me/Projects/my-project/node_modules/babel-register/lib/node.js:144:14)
    at Object.require.extensions.<computed> [as .js] (/Users/me/Projects/my-project/node_modules/babel-register/lib/node.js:154:7)
                                                                                                 ^^^^^^^^^^^^^^
    at require (/Users/me/Projects/my-project/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at WEBPACK_OPTIONS (/Users/me/Projects/my-project/node_modules/webpack-cli/bin/utils/convert-argv.js:114:13)
    at requireConfig (/Users/me/Projects/my-project/node_modules/webpack-cli/bin/utils/convert-argv.js:116:6)

★★★★★★★★★★★★★★★★★.webpack-cli하고 babel-register의인 - – – of of of of of of of of of of of of of of of of of of of of of of of of of of of of of of of of에 의해 지시된 것으로 추측됩니다.webpack-cli의 – 을 대상으로 합니다.@babel/babel-core설치했던 것보다 더 많이요.

해결 방법

를를 the the the the를 했습니다.webpack ★★★★★★★★★★★★★★★★★」webpack-cli, 삭제, 삭제node_modules/ ★★★★★★★★★★★★★★★★★」package-lock.json, 새로, 새로, 새로, 새로, 새로, 새로, , 이렇게npm install.

이 방법으로 즉시 동작하지 않는 경우는, 에러에 포함되는 제안을 따르는 것을 추천합니다.

오류: Babel "^7.0.0-0"이 필요하지만 "6.26.3"이 로드되었습니다.호환되는 버전의 @babel/core가 있는 경우 빌드 프로세스에서 잘못된 버전을 로드하고 있을 수 있습니다.이 에러의 스택트레이스를 조사하여 "@babel/core" 또는 "babel-core"를 언급하지 않은 첫 번째 엔트리를 검색하여 무엇이 Babel을 호출하는지 확인합니다.

의존관계 불일치의 원인(가장 가능성이 높은 것)을 특정합니다., 당신의 를 삭제할 것을 합니다.package.json의 »dependencies (및/또는)devDependenciesnpm 디폴트버전은 잘 됩니다.이러한 버전은, 서로 좋은 상태로 재생됩니다.필수가 아닌 의존관계를 삭제하고 디폴트 의존관계를 리셋하는 것이 최종적으로 기능합니다.

babel을 글로벌하게 설치하는 것은 권장되지 않습니다.IDE가 글로벌하게 설치된 패키지를 인식하고 이를 기반으로 하고 있을 수 있습니다.또는 패키지가 서로 경합하는 경우가 많습니다.예를 들어 babel-cli가 @babel/cli와 경합합니다.

Babel CLI를 컴퓨터에 글로벌하게 설치할 수 있지만 프로젝트별로 로컬로 설치하는 것이 훨씬 좋습니다.

yarn remove global @babel/cli @babel/core

프로젝트 디렉토리에서...

yarn remove babel-cli 
yarn add @babel/cli @babel/core @babel/node --dev

는 실수로 가 called called called called called called called called called called라는 파일을 가지고 ..babelrc다음 내용을 포함하는 루트 디렉토리에 있습니다.

{
  "presets": ["@babel/preset-env"]
}

후, 이 되었습니다.gulp명령어를 입력합니다.

로컬 버전이 있을 수 있으므로 글로벌버전이 실행되도록 해당 버전을 삭제합니다.

npm uninstall babel-cli
npm uninstall babel-core
  • 노드 모듈을 삭제합니다.
  • 개발 정보를 갱신하다
"devDependencies": {
      "@babel/core": "^7.13.10",
      "babel-core": "^7.0.0-bridge.0",
      ........
}
  • npm 설치

의 출력은 무엇입니까?npm ls babel-core?

여기에 이미지 설명 입력

이건 내 거야, 그래서 난 그걸 제거했어babel-cli@6.26.0그리고.babel-register@6.26.0부터package.json및 설치 완료@babel/cli그리고.@babel/register

잠금 파일을 삭제하고 다시 작성하는 것이 좋습니다.

  1. 삭제node_modules
  2. devDependencies 업데이트 대상:
"devDependencies": {
      "@babel/core": "^7.13.10",
      "babel-core": "^7.0.0-bridge.0",
}
  1. npm을 다시 설치합니다.
    npm install

언급URL : https://stackoverflow.com/questions/51873516/requires-babel-7-0-0-0-but-was-loaded-with-6-26-3

반응형