问答详情
源自:2-1 建立项目的 webpack 配置文件

按照老师的写webpack.config.js后运行报错

错误是

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
- configuration.output.path: The provided value "./dist/js" is not an absolute path!

有没有大神知道这个是为啥啊

提问者:向前走不回头 2017-07-14 18:36

个回答

  • QQ_随意
    2017-07-14 23:21:18
    已采纳

    var htmlWebpackPlugin = require('html-webpack-plugin');

    var path = require('path');

    module.exports = {

        entry: './src/script/main.js',

        output:{

             path:path.resolve(__dirname,'./dist/js'),

             filename:'[name].js'

    }

    }


  • 上官血浪
    2018-11-04 23:01:17

    我这个问题前面跟你的错误一样,后面就不一样了。不知道怎么改。

    Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.

     - configuration.module.rules[3].use should be one of these:

       non-empty string | function | object { ident?, loader?, options?, query? } | function | [non-empty string | function | object { ident?, loader?, options?, query? }]

       -> Modifiers applied to the module when rule is matched

       Details:

        * configuration.module.rules[3].use should be a string.

        * configuration.module.rules[3].use should be an instance of function

        * configuration.module.rules[3].use should be an object.

        * configuration.module.rules[3].use should be an instance of function

        * configuration.module.rules[3].use[0] should be a string.

        * configuration.module.rules[3].use[0] should be an instance of function

        * configuration.module.rules[3].use[0] has an unknown property 'option'. These properties are valid:

          object { ident?, loader?, options?, query? }


  • sinoey
    2018-04-03 11:53:42

    path: "./dist/js"
    改为:
    path: __dirname +"/dist/js"


  • 北极以北02
    2017-07-30 15:52:10

    webpack版本的问题,可以改成path: __dirname + '/dist/js',

  • 狂龙治中
    2017-07-16 12:03:59

    直接

    path: path.resolve(__dirname, 'dist'),

    不要./dist

  • 狂龙治中
    2017-07-16 12:02:52

    少了个  var path = require('path') 的引入

  • QQ_随意
    2017-07-14 23:25:14

    ./dist/js 把前面一点去了也可以 /dist/js 

  • QQ_随意
    2017-07-14 23:13:20

    也可能你没有建dist这个文件夹

  • QQ_随意
    2017-07-14 23:09:18

    output:{

        path:路径错误

    }

    不知道是不是,把代码复制出来看看,比较容易看那里错了