本来打算在package.json中的script脚本上增加参数 node -r babel-register 来实现webpack中使用es语法,在使用npm babel-register 后,运行脚本后出现
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.
原因是因为本地安装了babel 7.0版本,不兼容6.0的babel-register版本
解决方法:
npm i @babel/register, 再把package.json中的script上参数改成 node -r @babel/register