webpack报错:Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Cannot find module 'babel-preset-env' from '...' - Did you mean "@babel/env"?

  • webpack报错:Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Cannot find module ‘babel-preset-env‘ from ‘...‘ - Did you mean "@babel/env"?

    原因:

    babel-core和babel-preset-env依赖被替换为@babel/core和@babel/preset-env,因为新版本的Babel7中对官方提供的依赖使用了命名空间@babel

    npm install babel-loader babel-core babel-preset-env --save-dev

    npm install babel-loader @babel/core @babel/preset-env --save-dev

    解决:

    在.babelrc文件或在webpack.config.js文件中,将原来的env替换为@babel/preset-env

// .babelrc

{
  "presets": [
    ["env",
      {
        "modules": false
      }
    ]
  ]
}
// webpack.config.js

module: {
    rules: [
        {
            test: /\.js$/,
            exclude: /(node_modules)/,
            use: {
                loader: ‘babel-loader‘,
                options: {
                    presets: [‘env‘, { modules: false }]
                }
            }
        }
    ]
}
  • babel官方:https://babeljs.io/docs/en/babel-preset-env#browserslist-integration

webpack报错:Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Cannot find module 'babel-preset-env' from '...' - Did you mean "@babel/env"?

原文地址:https://www.cnblogs.com/cag2050/p/10087554.html

时间: 2024-10-11 10:31:19

webpack报错:Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Cannot find module 'babel-preset-env' from '...' - Did you mean "@babel/env"?的相关文章

Sass Loader报错:ValidationError: Invalid options object. Sass Loader has been initialised using an options object that does not match the API schema.

在vue.config.js中引入sass全局配置后报错vue.config.js代码如下: module.exports = { devServer: { port: 3333, open: true }, css: { loaderOptions: { sass: { data: `@import "@/assets/scss/_variable.scss";` } } } } _variable.scss的代码如下: $theme-color: #33aef0; 组件中的scss

vue.js报错:Module build failed: Error: No parser and no file path given, couldn't infer a parser.

ERROR Failed to compile with 2 errors 12:00:33 error in ./src/App.vue Module build failed: Error: No parser and no file path given, couldn't infer a parser. at normalize (C:\Users\admin\Desktop\222\demo\node_modules\prettier\index.js:7051:13) at form

【Vue报错】Module build failed: Error: No parser and no file path given, couldn't infer a p arser.

在创建一个vue项目启动时报错,报错的内容为: error in ./src/App.vue Module build failed: Error: No parser and no file path given, couldn't infer a p arser. at UndefinedParserError.Wrapper (D:\dyyc\bookstore\[email protected] [email protected]\index.js:1948:14) at new Und

Xamarin 示例Standard Controls报错:xamarin Failed to compile interface file. See Build Output for details

Standard Controls 示例下载地址: http://developer.xamarin.com/content/StandardControls/ Xamarin官网上的IOS示例“Standard Controls”编译报错: xamarin  Failed to compile interface file. See Build Output for details 搜索Xamarind 的forums,有几个帖子是关于相同错误信息的,貌似最权威的解答是下面这个: http:/

Module build failed: Error: Cannot find module 'node-sass’解决

在 npm run dev 时出现 ” Module build failed: Error: Cannot find module 'node-sass’ “ 这样的错误,如下: ERROR Failed to compile with 1 errors 19:51:09 error in ./src/page/Class/ClassList.vue Module build failed: Error: Cannot find module 'node-sass' Require stack

webpack报错:Cannot assign to read only property 'exports' of object '#<Object>'

这个倒霉错误在mac电脑上开发的时候非常顺利,可是用windows的时候就会报错. 百度查不到,google一查果然有. 原因是:The code above is ok. You can mix require and export. You can't mix import and module.exports. 也就是说,在webpack打包的时候,可以在js文件中混用require和export.但是不能混用import 以及module.exports. 于是查了一下代码,在自己的ma

iOS 报错: linker command failed with exit code 1 (use -v to see invocation) 原因

在iOS开发中,很多人会遇到这样的报错 linker command failed with exit code 1 (use -v to see invocation) 可能的原因如下: 1.引用出错,把***.h弄成了.m,检查一下你的所有引用: 2.再就是你引用第三方的库,你添加文件是系统没有所第三方库的.m文件参入的编译中去,你向项目添加文件得注意了; 3.找到Build settings->Linking->Other Linker Flags,将此属性修改成-all_load或-O

关于spring-data-mongodb用户名密码登录报错问题:Failed to authenticate to database

一.问题 1.spring-data-mongodb用户名密码登录报错问题:Failed to authenticate to database  org.springframework.data.mongodb.CannotGetMongoDbConnectionException: Failed to authenticate to database [ashop], username = [ashop], password = [g***********4] org.springframe

编译android源码报错:build/envsetup.sh: 1: Syntax error:

编译android源码时报错: build/envsetup.sh: 1: Syntax error: "(" unexpected 解决方法: 执行$sudo dpkg-reconfigure dash命令,并选择"否" 编译android源码报错:build/envsetup.sh: 1: Syntax error: