2

In setting up webpacker with my Rails 5.2.4 app, I've introduced this bug to my browser console: 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 is not a real package, so what does this mean? Looking through that index.js file I see no mention of babel-plugin-syntax-dynamic-import. Furthermore, said plugin is stored in node_modules/@babel/babel-plugin-syntax-dynamic-import. After reading this I made sure that all my babel packages were on version 7. Except for babel-loader v8, because v7 was looking for an incorrect dependency.

My package.json looks alright as far as I can tell:

{
  "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"
}

Also, there is no leftover .babelrc file in my root.

calyxofheld
  • 1,538
  • 3
  • 24
  • 62

1 Answers1

1

Solution was to downgrade babel-loader@8.1.0 to babel-loader@8.0.6

calyxofheld
  • 1,538
  • 3
  • 24
  • 62