【问题标题】:Invalid configuration object output.path is not an absolute path无效的配置对象 output.path 不是绝对路径
【发布时间】:2017-08-19 02:28:12
【问题描述】:

我尝试使用 webpack 将“.ts”编译为“.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" is not an absolute path!"

【问题讨论】:

    标签: javascript typescript webpack


    【解决方案1】:

    output.path 需要一个绝对路径,但你给它的是一个相对路径./dist。您需要将其转换为绝对路径,例如使用path.resolve

    const path = require('path');
    
    module.exports = {
      output: {
        path: path.resolve(__dirname, 'dist'),
        // Your other output options
      },
      // Rest of your config
    };
    

    【讨论】:

    • 谢谢它对我的帮助!
    • 我在安装 SASS 后遇到了同样的问题 *** npm install sass-loader node-sass webpack --save-dev 给定的解决方案得到了工作。是什么原因?自从我开始工作以来,它在路径上没有出现任何问题。 stackoverflow.com/questions/43742252/…
    猜你喜欢
    • 2017-07-23
    • 2017-06-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-20
    • 2021-07-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多