【发布时间】:2021-01-03 19:43:32
【问题描述】:
在使用我的 Rails 5.2.4 应用程序设置 webpacker 时,我在浏览器控制台中引入了这个错误:Uncaught Error: Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Cannot find module 'babel-plugin-syntax-dynamic-import' from '/Users/me/code/project' - Did you mean "@babel/syntax-dynamic-import"
@babel/syntax-dynamic-import 不是真正的包,那么这是什么意思呢?浏览那个index.js 文件,我没有看到babel-plugin-syntax-dynamic-import 的提及。此外,所述插件存储在node_modules/@babel/babel-plugin-syntax-dynamic-import中。在阅读了this 之后,我确定我所有的 babel 包都在版本 7 上。除了babel-loader v8,因为 v7 正在寻找不正确的依赖项。
据我所知,我的 package.json 看起来还不错:
{
"dependencies": {
"@babel/core": "^7.11.6",
"@babel/plugin-proposal-class-properties": "^7.10.4",
"@babel/plugin-proposal-object-rest-spread": "^7.11.0",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/preset-env": "^7.11.5",
"@babel/preset-react": "^7.10.4",
"@rails/webpacker": "5.2.1",
"babel-loader": "^8.1.0",
"micromodal": "^0.4.6",
"prop-types": "^15.6.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"semantic-ui": "2.4.2",
"uppy": "^1.21.1"
},
"devDependencies": {
"webpack-dev-server": "^3.11.0"
},
"version": "0.0.0"
}
另外,我的根目录中没有剩余的 .babelrc 文件。
【问题讨论】:
标签: ruby-on-rails babeljs webpacker