Preset files are not allowed to export objects

前端 未结 10 977
梦如初夏
梦如初夏 2020-11-30 01:18

I have a carousel file in which I want to get index.js and build block.build.js, so my webpack.config.js is:



        
相关标签:
10条回答
  • 2020-11-30 01:55

    Also from babel-loader v8, they have changed a little bit:

    webpack 4.x | babel-loader 8.x | babel 7.x

    npm install -D babel-loader @babel/core @babel/preset-env webpack
    

    webpack 4.x | babel-loader 7.x | babel 6.x

    npm install -D babel-loader@7 babel-core babel-preset-env webpack
    

    (same thing for @babel/preset-react instead of babel-preset-react).

    0 讨论(0)
  • 2020-11-30 01:59

    this worked for me:

    npm uninstall --save babel-loader
    npm uninstall --save @babel/core
    npm install --save-dev babel-loader@^7
    

    and in babelrc:

    "presets" : ["es2015", "react"]    
    
    0 讨论(0)
  • 2020-11-30 02:00

    It happened to me and a simple solution for me was to uninstall babel-loader@8^ and @babel/core:

    npm uninstall --save babel-loader
    npm uninstall --save @babel/core
    

    … and then to install version 7 babel-loader:

    npm install --save-dev babel-loader@^7
    
    0 讨论(0)
  • 2020-11-30 02:00

    Replace your .babelrc file following code this fix my issue

    {
      "presets": ["module:metro-react-native-babel-preset"]
    }
    
    0 讨论(0)
  • 2020-11-30 02:05

    You're using a combination of Babel 6 and Babel 7. There is no guarantee of compatibility across versions:

    "@babel/core": "^7.0.0-beta.40",
    "babel-cli": "^6.26.0",
    "babel-loader": "^8.0.0-beta.0",
    "babel-plugin-lodash": "^3.3.2",
    "babel-plugin-react-transform": "^3.0.0",
    "babel-preset-react": "^6.24.1",
    

    should be

    "@babel/core": "^7.0.0-beta.40",
    "@babel/cli": "^7.0.0-beta.40",
    "babel-loader": "^8.0.0-beta.0",
    "babel-plugin-lodash": "^3.3.2",
    "babel-plugin-react-transform": "^3.0.0",
    "@babel/preset-react": "^7.0.0-beta.40",
    

    and

        query: {
          presets: ['react', 'es2015'],
          plugins: ['transform-class-properties']
        }
    

    would be

        query: {
          presets: ['@babel/react', '@babel/es2015'],
          plugins: ['@babel/proposal-class-properties']
        }
    

    I'm also confused because you didn't mention @babel/proposal-class-properties in your package.json, but assuming it is in there it should also be updated.

    0 讨论(0)
  • 2020-11-30 02:05

    This solution worked for me:

    npm install babel-loader babel-preset-react
    

    then in .babelrc

    {
      "presets": [
        "@babel/preset-env", "@babel/preset-react"
      ]
    }
    

    then run npm run start, webpack will generate the dist directory.

    0 讨论(0)
提交回复
热议问题