如何解决React.js:无法使Material Kit React框架正常工作需要加载器,但无法确定是哪个
我有一个带有React和“ Material Kit React”框架的项目,我需要“ Material Kit React”中的NavPills。但是,当我在项目目录npm run dev-server
中运行时,出现此错误:
ERROR in ./node_modules/material-kit-react/src/components/NavPills/NavPills.js 36:4
Module parse failed: Unexpected token (36:4)
You may need an appropriate loader to handle this file type,currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| });
| const tabButtons = (
> <Tabs
| classes={{
| root: classes.root,@ ./src/components/Example.js 2:0-78 4:2-10 8:2-10 24:42-50
@ ./src/app.js
...这是一个奇怪的错误,因为在./src/components/Example.js
中,例如第2行没有字符,但是消息中有2:0-78
(所以78个字符)。没关系。
./src/components/Example.js
来自https://demos.creative-tim.com/material-kit-react/?_ga=2.143740725.1047547723.1597769295-253355442.1597657665#/documentation/nav-pills
此错误是什么意思?这个appropriate loader
应该是.js
的加载程序吗?因为我在webpack.config.js
中有这样的加载程序:
module: {
rules: [
{
loader: "babel-loader",test: /\.js$/,exclude: /node_modules/,query: {
presets: ['@babel/preset-react','@babel/preset-env'],plugins: ['@babel/plugin-proposal-class-properties']
}
},{
test: /\.s?css$/,use: ["style-loader","css-loader","sass-loader"]
}
]
}
我尝试过的
我已从Babel 6迁移到Babel 7,因为“材料包反应”是必需的。例如。我已将babel-core
更改为@babel/core
或将babel-cli
更改为@babel/cli
。
我也修改了我的webpack.config.js
-添加了query.presets
和query.plugins
,所以看起来像上面的一样。
我还为.babelrc
添加了预设和插件:
{
"presets": ["@babel/preset-env","@babel/preset-react"],"plugins": ["@babel/plugin-proposal-class-properties"]
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。