无效的配置对象output.path不是绝对路径

时间:2017-03-26 12:08:27

标签: javascript typescript webpack

我尝试编译" .ts" to" .js"使用webpack但是出现此错误,我该如何解决这个问题?

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!"

1 个答案:

答案 0 :(得分:32)

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
};