question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot find module 'babel-preset-env'

See original GitHub issue

I’m submitting a bug report

Webpack Version: 3.12

Babel Core Version: 7.0.0-beta.46 (also “@babel/preset-env”: “^7.0.0-beta.46”)

Babel Loader Version: 8.0.0-beta.2

Please tell us about your environment: Windows 10

Current behavior: Error: “Cannot find module ‘babel-preset-env’ from (root of my project)”

Expected/desired behavior:

         use: [{
            loader: 'babel-loader',
            options: {
              presets: [
                ['@babel/preset-env', { modules: false }]
              ]
            }
          }]

should load correctly, given the loader and babel versions

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem along with a gist/jsbin of your webpack configuration.

Snippet. My config is very basic, otherwise

module: {
      rules: [
        {
          test: /\.js$/,
          exclude: resolve('node_modules'),
          use: [{
            loader: 'babel-loader',
            options: {
              presets: [
                ['@babel/preset-env']
              ]
            }
          }]
        }
      ]
    }

Webpack being called from a node script in this way:

const webpackConfig = require('./webpack.config.babel')('dev');

function webpackInit() {
  const compiler = webpack(webpackConfig);
  return new Promise((resolve, reject) => {
    compiler.run((err, stats) => {
      console.log(`compiler has been started`);
      if (err || stats.hasErrors()) {
        const _err = err ? err : JSON.stringify(stats.toJson('errors-only'));
        reject(_err);
      }
      resolve('webpack has been started');
    });
  })
    .then(resp => console.log(response))
    .catch(e => console.error(`Error : ${e}`));
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:9
  • Comments:20 (3 by maintainers)

github_iconTop GitHub Comments

162reactions
loganfsmythcommented, May 2, 2018

Sounds like you probably have a .babelrc that is still referencing babel-preset-env.

157reactions
Josh68commented, May 2, 2018
"babel": {
    "presets": [
      [
        "@babel/preset-env",
        {
          "modules": "commonjs",
          "targets": {
            "node": "current"
          }
        }
      ]
    ]
  },

was just env

fixed the issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot find module 'babel-preset-env' from PATH Did you ...
I'm sure it is some kind of incompatibility between a module which uses babel 6 and my project with babel 7, but I'm...
Read more >
Cannot find module '@babel/preset-env' error in Node.js
The error "Cannot find name '@babel/preset-env'" occurs when we use the @babel/preset-env module before installing it. To solve the error, install the @babel/ ......
Read more >
@babel/preset-env - npm
A Babel preset for each environment. See our website @babel/preset-env for more information or the issues associated with this package.
Read more >
babel/preset-env
babel /preset-env` is a smart preset that allows you to use the latest JavaScript without needing to micromanage which syntax transforms (and optionally, ......
Read more >
Error: Cannot find module 'babel/preset-react' - Replit
/preset-env. @babel. /preset-react babel-plugin-transform-class-properties. For the information, I created the repl using Django Template.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found