Heim  >  Fragen und Antworten  >  Hauptteil

Javascript – Fehler bei der Webpack-Kompilierung Konnte die Voreinstellung „Reagieren“ relativ zum Verzeichnis nicht finden

webpack.config.js:

let webpack = require('webpack');
let path = require('path');

module.exports = {
    context:__dirname + '/src',
    entry:"./js/index.js",
    module:{
        loaders:[
          {
            test: /\.js?$/,
            exclude: /node_modules/,
            loader:'babel-loader',
            query:{
                presets:['es2015','react']
            }
          }
      ]
    },
    output:{
        path:__dirname + "/src",
        filename:"bundle.js"
    }
};

package.json:

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "antd": "^2.1.0",
    "babel": "^5.8.23",
    "babel-core": "^6.24.1",
    "babel-loader": "^6.4.1",
    "babel-preset-es2015": "^6.24.0",
    "babel-preset-react": "^6.23.0",
    "react": "^15.3.2",
    "react-dom": "^15.3.2",
    "webpack": "^2.4.1",
    "webpack-dev-server": "^2.4.4"
  }
}
漂亮男人漂亮男人2733 Tage vor920

Antworte allen(1)Ich werde antworten

  • 我想大声告诉你

    我想大声告诉你2017-05-19 10:33:05

    webpack 配置没问题。报错应该是 babel query 那里有问题。

    1. 第一种解决方法:presets:['es2015','react']map(require.resolve)

    2. 第一种没解决,就把query删掉,在根目录下新建.babelrcquery 这个json对象放进去

    3. 第二种也没解决的话,升级一下babel相关的插件的版本,重复上面的步骤。

    Antwort
    0
  • StornierenAntwort