问题描述
我正在尝试设置皮带。我成功地创建了应用程序。但是当我运行命令 yarn develop 我得到以下错误
Error: ./.cache/plugins/strapi-plugin-content-manager/admin/src/components/RepeatableComponent/Banner.js 2:87
Module parse Failed: Unexpected token (2:87)
File was processed with these loaders:
* ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
到目前为止我尝试过的:
我在 Strapi 网站或 github 问题上找不到任何有用的内容
解决方法
最后, 我设法解决了这个问题。 您需要更新 webpack.config.js 来自
require.resolve('@babel/preset-env')
到
[require.resolve('@babel/preset-env'),{ targets: "defaults" }]
在模块选项内
,您可以在这里找到更准确的答案:https://stackoverflow.com/a/68531196/13282460
引用?
"1. 更好的解决方案。
检查你的 Strapi 项目是否嵌套在另一个使用 babel/webpack 的项目中。我的所有项目目录中都有一些旧文件。当我删除它们时,它起作用了。
2.解决方案(随着每个包的更新,它将恢复到早期版本)
- 在您的 Strapi 文件夹中,转到 → node_modules/strapi-admin/webpack.config.js
- 找到该行 → require.resolve('@babel/preset-env')
- 将其替换为 [require.resolve('@babel/preset-env'),{ targets: 'defaults' }],
- 运行命令 - npm run dev"