Cannot find module '@babel/plugin-transform-runtime' from
Asked Answered
B

4

20

I m getting the error " Cannot find module '@babel/plugin-transform-runtime' from ...". I have tried every solution on the internet but nothing really works. How can i solve it ? Any suggestion would be greatly appriciated.

babelrc

{
    "presets": [
        "@babel/preset-react",
        "@babel/preset-env"
    ],
    "plugins": [
        ["transform-runtime", {
            "helpers": false, // defaults to true
            "polyfill": false, // defaults to true
            "regenerator": true, // defaults to true
            "moduleName": "babel-runtime" // defaults to "babel-runtime"
        }]
    ]}

webpack

var HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');

module.exports = {
    mode: 'development',
    resolve: {
        extensions: ['.js', '.jsx', '.css']
    },
    module: {
        rules: [
            {
                test: /\.jsx?$/,
                loader: 'babel-loader'
            },
            {
                test: /\.css$/,
                use: [ 'style-loader', 'css-loader' ]
            }
        ]
    },
    resolve: {
        extensions: ['.js', '.jsx', '.css'],
        alias: {
            '@': path.resolve(__dirname, 'src/'),
        }
    },

    plugins: [new HtmlWebpackPlugin({
        template: './src/index.html'
    })],
    devServer: {
        historyApiFallback: true
    },
    externals: {
        // global app config object
        config: JSON.stringify({
            apiUrl: 'https://obidentity-develop.azurewebsites.net/connect/token'
        })
    }
}
Balmuth answered 28/2, 2020 at 20:45 Comment(11)
Have you installed it?, ie- npm install @babel/plugin-transform-runtime ?Foible
yes i have triedBalmuth
Is it listed in your package.json file?Foible
Oh, I see a problem, in your .babelrc, it should be, "plugins": [["@babel/plugin-transform-runtime",.. , not just "transform-runtime".Foible
i just tried it. Same result...Balmuth
"@babel/plugin-transform-runtime": "^7.8.3", "@babel/runtime": "^7.8.4", "babel-runtime": "^6.26.0", "babel-plugin-transform-runtime": "^6.23.0"Balmuth
You have All of those installed? You want only one.Foible
This would be impossible to debug for you. Would need to evaluate the specific errors and other factors. Just read the errors closely and debug from there. good luck! Or maybe someone else will have some insight.Foible
Does it work if you change your @ alias to @/?Khajeh
I was getting the same error in Create-React-App (CRA) when overriding the build config without ejecting. Installing the plugin with yarn add -D @babel/plugin-transform-runtime fixed it.Inchoative
add everything under dependencies: {} instead of devDependencies: {}. This fixed issue for me. Also, answer below is correct as well. and do npm i -g jest as well.Glop
P
15

try to add

"plugins": ["@babel/plugin-transform-runtime"]

in .babelrc

Proctology answered 2/9, 2020 at 22:41 Comment(0)
L
3

I met this problem when I was running 2 different versions of node:

  • terminal 1: node 14, npm install
  • terminal 2: node 16, npm run dev

so the dependencies are mess up, and something very strange happens.

solution:

  1. remove node_modules folder
  2. open 1 terminal, npm install and npm run dev
Lanettelaney answered 2/2, 2022 at 4:18 Comment(0)
D
0

I deleted ".babelrc".

Then I use: npm run dev.

That fix the problem.

Duffel answered 25/10, 2022 at 11:54 Comment(0)
L
0

babel-preset-react-app, is importing the "@babel/plugin-proposal-private-property-in-object" package without declaring it in its dependencies

^ The first answer here fixed it for me, except instead of adding babel-preset-react-app, I substituted it for "@babel/plugin-transform-runtime" as below

  1. npm install --save-dev @babel/plugin-transform-runtime
  2. Add the following to your .eslintrc file { "extends": ["eslint:recommended", "@babel/plugin-transform-runtime"], ... }
Lyublin answered 1/5 at 12:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.