首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >@ babel /预设-env在升级babel 6到7后加载错误的babel版本

@ babel /预设-env在升级babel 6到7后加载错误的babel版本
EN

Stack Overflow用户
提问于 2018-10-12 03:57:37
回答 1查看 705关注 0票数 0

我试图将我的babel从6升级到7,但我遇到了这个问题。

代码语言:javascript
复制
/Users/darryl/Documents/Github/apps/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/options/option-manager.js:328
        throw e;
        ^

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: "/Users/darryl/Documents/Github/apps/node_modules/@babel/preset-env/lib/index.js")
    at throwVersionError (/Users/darryl/Documents/Github/apps/node_modules/@babel/preset-env/node_modules/@babel/helper-plugin-utils/lib/index.js:65:11)
    at Object.assertVersion (/Users/darryl/Documents/Github/apps/node_modules/@babel/preset-env/node_modules/@babel/helper-plugin-utils/lib/index.js:13:11)
    at _default (/Users/darryl/Documents/Github/apps/node_modules/@babel/preset-env/lib/index.js:154:7)
    at /Users/darryl/Documents/Github/apps/node_modules/@babel/preset-env/node_modules/@babel/helper-plugin-utils/lib/index.js:19:12
    at /Users/darryl/Documents/Github/apps/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/options/option-manager.js:317:46
    at Array.map (<anonymous>)
    at OptionManager.resolvePresets (/Users/darryl/Documents/Github/apps/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
    at OptionManager.mergePresets (/Users/darryl/Documents/Github/apps/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)
    at OptionManager.mergeOptions (/Users/darryl/Documents/Github/apps/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14)
    at OptionManager.init (/Users/darryl/Documents/Github/apps/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
    at compile (/Users/darryl/Documents/Github/apps/node_modules/babel-register/lib/node.js:103:45)
    at loader (/Users/darryl/Documents/Github/apps/node_modules/babel-register/lib/node.js:144:14)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/darryl/Documents/Github/apps/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Function.Module.runMain (module.js:684:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3

有人能帮我解释一下发生了什么吗?我尝试删除node_modules和Packy-lock.json,并运行npm cache clean --force

但是这个错误仍然发生。如何强迫这种依赖(@ Babel /预设-env)在依赖项中使用Babel 7而不是Babel 6.26.3?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-10-12 04:57:36

正如loganfsmyth所提到的,请执行

代码语言:javascript
复制
npm i -D @babel/register

帮助我解决仍然使用Babel版本6的babel-register依赖关系的问题。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52772039

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档