Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

taro2.2.15编译babel报错 #7962

Open
jarmywang opened this issue Nov 3, 2020 · 4 comments
Open

taro2.2.15编译babel报错 #7962

jarmywang opened this issue Nov 3, 2020 · 4 comments
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-2 Version - 2.x

Comments

@jarmywang
Copy link

相关平台

微信小程序

小程序基础库: 2.14.0
使用框架: React

复现步骤

1、我从v2.1.3升级到v2.2.15,更新package.json

  "dependencies": {
    "bind-decorator": "1.0.11",
    "classnames": "2.2.6",
    "dayjs": "1.7.7",
    "prop-types": "15.7.2",
    "sentry-miniapp": "0.9.8",
    "solarlunar": "2.0.3",
    "taro-skeleton": "1.2.2",
    "@tarojs/components": "2.2.15",
    "@tarojs/components-qa": "2.2.15",
    "@tarojs/redux": "2.2.15",
    "@tarojs/redux-h5": "2.2.15",
    "@tarojs/router": "2.2.15",
    "@tarojs/taro": "2.2.15",
    "@tarojs/taro-h5": "2.2.15",
    "@tarojs/taro-weapp": "2.2.15",
    "babel-runtime": "6.26.0",
    "nervjs": "1.5.5",
    "nerv-devtools": "1.5.5",
    "redux": "4.0.0",
    "redux-logger": "3.0.6",
    "redux-thunk": "2.3.0",
    "regenerator-runtime": "0.11.1"
  },
  "devDependencies": {
    "fuzzy": "0.1.3",
    "inquirer": "7.0.3",
    "inquirer-autocomplete-prompt": "1.0.2",
    "overassert": "1.0.3",
    "@types/react": "16.4.8",
    "@types/webpack-env": "1.13.6",
    "@tarojs/mini-runner": "2.2.15",
    "@tarojs/plugin-sass": "2.2.15",
    "@tarojs/plugin-terser": "2.2.15",
    "@tarojs/webpack-runner": "2.2.15",
    "babel-plugin-transform-class-properties": "6.24.1",
    "babel-plugin-transform-decorators-legacy": "1.3.4",
    "babel-plugin-transform-jsx-stylesheet": "0.6.5",
    "babel-plugin-transform-object-rest-spread": "6.26.0",
    "babel-plugin-transform-runtime": "6.23.0",
    "babel-preset-env": "1.6.1",
    "babel-eslint": "8.2.3",
    "eslint": "5.16.0",
    "eslint-config-taro": "2.2.15",
    "eslint-plugin-react": "7.8.2",
    "eslint-plugin-react-hooks": "1.6.1",
    "eslint-plugin-import": "2.12.0",
    "stylelint": "9.3.0",
    "stylelint-config-taro-rn": "2.2.15",
    "stylelint-taro-rn": "2.2.15",
    "eslint-plugin-taro": "2.2.15",
    "@typescript-eslint/eslint-plugin": "2.13.0",
    "@typescript-eslint/parser": "2.13.0",
    "typescript": "3.2.1"
  },

2、config babel部分:

  babel: {
    sourceMap: true,
    presets: [
      [
        'env',
        {
          modules: false
        }
      ]
    ],
    plugins: [
      'transform-decorators-legacy',
      'transform-class-properties',
      'transform-object-rest-spread',
      [
        'transform-runtime',
        {
          helpers: false,
          polyfill: false,
          regenerator: true,
          moduleName: 'babel-runtime'
        }
      ]
    ]
  },

3、出现错误:Requires Babel "^7.0.0-0", but was loaded with "6.26.3". 编译失败.

期望结果

编译成功

实际结果

编译失败

环境信息

� Taro v2.2.15

  Taro CLI 2.2.15 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 12.16.2 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.22.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
      npm: 6.14.4 - C:\Program Files\nodejs\npm.CMD


补充信息

报错内容:

Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are sure yo
u have a compatible version of @babel/core, it is likely that something in your bu
ild 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 se
e what is calling Babel.
    at throwVersionError (D:\develop\WebstormProjects\2haohr\packages\mp\node_modu
les\@babel\helper-plugin-utils\lib\index.js:65:11)
    at Object.assertVersion (D:\develop\WebstormProjects\2haohr\packages\mp\node_m
odules\@babel\helper-plugin-utils\lib\index.js:13:11)
    at D:\develop\WebstormProjects\2haohr\packages\mp\node_modules\@babel\plugin-p
roposal-decorators\lib\index.js:19:7
    at D:\develop\WebstormProjects\2haohr\packages\mp\node_modules\@babel\helper-p
lugin-utils\lib\index.js:19:12
    at Function.memoisePluginContainer (D:\develop\WebstormProjects\2haohr\package
s\mp\node_modules\@tarojs\mini-runner\node_modules\babel-core\lib\transformation\f
ile\options\option-manager.js:113:13)
    at Function.normalisePlugin (D:\develop\WebstormProjects\2haohr\packages\mp\no
de_modules\@tarojs\mini-runner\node_modules\babel-core\lib\transformation\file\opt
ions\option-manager.js:146:32)
    at D:\develop\WebstormProjects\2haohr\packages\mp\node_modules\@tarojs\mini-ru
nner\node_modules\babel-core\lib\transformation\file\options\option-manager.js:184
:30
    at Array.map (<anonymous>)
    at Function.normalisePlugins (D:\develop\WebstormProjects\2haohr\packages\mp\n
ode_modules\@tarojs\mini-runner\node_modules\babel-core\lib\transformation\file\op
tions\option-manager.js:158:20)
    at OptionManager.mergeOptions (D:\develop\WebstormProjects\2haohr\packages\mp\
node_modules\@tarojs\mini-runner\node_modules\babel-core\lib\transformation\file\o
ptions\option-manager.js:234:36)
    at OptionManager.init (D:\develop\WebstormProjects\2haohr\packages\mp\node_mod
ules\@tarojs\mini-runner\node_modules\babel-core\lib\transformation\file\options\o
ption-manager.js:368:12)
    at File.initOptions (D:\develop\WebstormProjects\2haohr\packages\mp\node_modul
es\@tarojs\mini-runner\node_modules\babel-core\lib\transformation\file\index.js:21
2:65)
    at new File (D:\develop\WebstormProjects\2haohr\packages\mp\node_modules\@taro
js\mini-runner\node_modules\babel-core\lib\transformation\file\index.js:135:24)
    at Pipeline.transform (D:\develop\WebstormProjects\2haohr\packages\mp\node_mod
ules\@tarojs\mini-runner\node_modules\babel-core\lib\transformation\pipeline.js:46
:16)
    at Object.wxTransformerLoader (D:\develop\WebstormProjects\2haohr\packages\mp\
node_modules\@tarojs\mini-runner\dist\loaders\wxTransformerLoader.js:93:38)
    at LOADER_EXECUTION (D:\develop\WebstormProjects\2haohr\packages\mp\node_modul
es\loader-runner\lib\LoaderRunner.js:119:14)
    at runSyncOrAsync (D:\develop\WebstormProjects\2haohr\packages\mp\node_modules
\loader-runner\lib\LoaderRunner.js:120:4)
    at iterateNormalLoaders (D:\develop\WebstormProjects\2haohr\packages\mp\node_m
odules\loader-runner\lib\LoaderRunner.js:232:2)
    at Array.<anonymous> (D:\develop\WebstormProjects\2haohr\packages\mp\node_modu
les\loader-runner\lib\LoaderRunner.js:205:4)
    at Storage.finished (D:\develop\WebstormProjects\2haohr\packages\mp\node_modul
es\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
    at D:\develop\WebstormProjects\2haohr\packages\mp\node_modules\enhanced-resolv
e\lib\CachedInputFileSystem.js:91:9
    at D:\develop\WebstormProjects\2haohr\packages\mp\node_modules\graceful-fs\gra
    at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_con
text.js:63:3) {
  code: 'BABEL_VERSION_UNSUPPORTED',
  version: '6.26.3',
  range: '^7.0.0-0'
}
�   编译失败.

我尝试过升级babel到7:@babel/xxx的写法:

"@babel/runtime": "^7.12.1",

"babel-core": "7.0.0-bridge.0",
"@babel/core": "^7.12.3",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/plugin-proposal-decorators": "^7.12.1",
"@babel/plugin-proposal-object-rest-spread": "^7.12.1",
"@babel/plugin-transform-react-jsx": "^7.12.1",
"@babel/plugin-transform-runtime": "^7.12.1",
"@babel/preset-env": "^7.12.1",
"babel-eslint": "^10.1.0",

对应
config babel部分改动:

'@babel/plugin-proposal-decorators',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-object-rest-spread',
...
moduleName: '@babel/runtime'

也是一样的报错,然后我尝试了强制降级到babel6:"@babel/core": "6.0.0-bridge.1", 也失败了

@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-2 Version - 2.x labels Nov 3, 2020
@daimashenjing
Copy link

我也是相同的问题

@EwanBerg
Copy link

我也是相同的问题

是不是因为引用了一些不支持的包。譬如我引用了alibaba/form-render 而form-render又依赖antd 。也是报的这个错误。

@ThorLei
Copy link

ThorLei commented Aug 1, 2021

怎么解决的?也不解决吗?

@jamninetyfive
Copy link

怎么解决的?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-2 Version - 2.x
Projects
None yet
Development

No branches or pull requests

5 participants