[英]Materialui upgrade “You may need an appropriate loader to handle this file type.” issue
I'm very new to React, Webpack, Babel and web development as well. 我对React,Webpack,Babel和Web开发也很陌生。 The company I work for asked me to upgrade
material-ui
for the use of search in a dropdown component. 我工作的公司要求我升级
material-ui
以便在下拉组件中使用搜索。 However, the project is old and the material-ui
version was used in the project is "1.0.0-beta.43". 但是,该项目较旧,该项目中使用的
material-ui
版本为“ 1.0.0-beta.43”。 I upgraded it to "@material-ui/core": "^1.0.0" for starters, didn't want to upgrade to the latest version as it's dependencies could ruin all project. 我将其升级为“ @ material-ui / core”:初学者为“ ^ 1.0.0”,由于其依赖项可能会破坏所有项目,因此不想升级至最新版本。 I saw the @babel/runtime": "^7.1.2 dependency and installed it too.
我看到了@ babel / runtime“:” ^ 7.1.2依赖项,并且也安装了它。 And now when I try to run the project I get the error below, what should I do to solve this?
现在,当我尝试运行项目时,出现以下错误,该怎么办才能解决此问题? I would really appreciate the help.
我非常感谢您的帮助。
ERROR in ./src/main.js Module parse failed: C:\\Work\\STYS_Frontend\\src\\main.js Unexpected token (109:16) You may need an appropriate loader to handle this file type. ./src/main.js中的错误模块解析失败:C:\\ Work \\ STYS_Frontend \\ src \\ main.js意外的令牌(109:16)您可能需要适当的加载程序来处理此文件类型。
The line that's mentioned in the error is ReactDOM.render(, document.getElementById("content")); 错误中提到的行是ReactDOM.render(,document.getElementById(“ content”)));
My package.json and webpack config attached and I have .babelrc in the root document which looks like: 附加了我的package.json和webpack配置,并且根文档中有.babelrc,如下所示:
{ "presets": ["es2015", "stage-0", "react"] }
Since you have install @babel/runtime, you need to update or install 由于已安装@ babel / runtime,因此需要更新或安装
@babel/core,
@babel/plugin-proposal-class-properties,
@babel/plugin-syntax-dynamic-import,
@babel/plugin-transform-runtime,
@babel/preset-env,
@babel/preset-react,
@babel/preset-stage-0,
And for your .babelrc 对于你的.babelrc
{
"presets": ["@babel/preset-env", "@babel/preset-react" ],
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-transform-runtime"
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.