Error: Cannot find module '@babel/core' processing

Error: Cannot find module '@babel/core' processing

  • When installing babel, I encountered a **Error: Cannot find module '@babel/core'** problem. I checked a lot of information to solve it. I hope it can help you brothers.

Cause of the problem

The babel-loader and babel-core versions do not correspond to the generated,

  • babel-loader 8.x corresponds to babel-core 7.x
  • babel-loader 7.x corresponds to babel-core 6.x

How to solve

1. Uninstall the old babel-core
npm un babel-core
2. Install the new babel-core
npm i -D @babel/core
3. Uninstall the old babel-preset
npm un babel-preset-env
npm un babel-preset- stage-0
4. Install the new babel-preset
npm i @babel/preset-react
npm i @babel/preset-env
npm i babel-preset-mobx
5. Uninstall the old babel-plugin
npm un babel-plugin-transform- runtime
6. Install the new babel-plugin
npm install --save-dev @babel/plugin-proposal-object-rest-spread
npm install --save-dev @babel/plugin-transform-runtime
npm install --save @babel /runtime
7. Modify the .babelrc file

{
    "presets": ["@babel/preset-env", "@babel/preset-react", "mobx"],
    "plugins": [
        "@babel/plugin-proposal-object-rest-spread",
        "@babel/plugin-transform-runtime"
    ]
}

  • After you install it according to the above command, the corresponding version should be as shown in the figure below, and the problem should be solved.
"devDependencies": {
    "@babel/core": "^7.2.2",
    "@babel/plugin-proposal-object-rest-spread": "^7.2.0",
    "@babel/plugin-transform-runtime": "^7.2.0",
    "@babel/preset-env": "^7.2.3",
    "@babel/preset-react": "^7.0.0",
    "babel-loader": "^8.0.4",
    "babel-preset-mobx": "^2.0.0",
    "css-loader": "^2.1.0",
    "file-loader": "^3.0.1",
    "popper.js": "^1.14.6",
    "style-loader": "^0.23.1",
    "url-loader": "^1.1.2",
    "webpack": "^4.28.2",
    "webpack-cli": "^3.1.2"
  },
  "dependencies": {
    "@babel/runtime": "^7.2.0",
    "bootstrap": "^4.2.1",
    "jquery": "^3.3.1"
  }

Guess you like

Origin blog.csdn.net/weixin_42202992/article/details/132133624