Error: could not find the pre-installed "es2015" relative to the directory

I get the following error when I try to use babel.

Error: could not find the pre-installed "es2015" relative to the directory

webpack.config.js

module.exports = {
    entry: './main.js',
    ourput: {
        path:'./',
        filename:'index.js'
    },
    devServer:{
        inline:true,
        port:3333
    },
    module:{
        loaders:[
            {
                test:/\.js$/,
                exclude:/node_modules/,
                loader:'babel',
                query:{
                    presets:['es2015','react']
                }
            }
        ]
    }
}

package.json

{
  "name": "es6-react-setup",
  "version": "1.0.0",
  "main": "main.js",
  "dependencies": {
    "babel-core": "^6.11.4",
    "babel-preset-es2015": "^6.9.0",
    "babel-preset-react": "^6.11.1",
    "babel-loader": "^6.2.4",
    "react": "^15.2.1",
    "react-dom": "^15.2.1",
    "webpack": "^1.13.1"
  },
  "devDependencies": {},
  "scripts": {
    "start": "webpack-dev-server"
  },
  "author": "",
  "license": "ISC",
  "description": ""
}

Terminal output Terminal output

+8
source share
2 answers

You need babel to configure these presets. You can add this to yourpackage.json

  "babel": {
    "presets": [
      "es2015",
      "react"
    ]
  },

Alternatively, you can have a file .babelrc.

https://babeljs.io/docs/usage/babelrc/

+12
source

try it

npm install babel-preset-es2015

npm install babel-preset-react

npm install babel --save-dev

It worked for me.

+4
source

Source: https://habr.com/ru/post/1685669/


All Articles