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

Hov*_*yan 7 javascript typescript webpack

我尝试使用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!"
Run Code Online (Sandbox Code Playgroud)

Mic*_*ngo 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
};
Run Code Online (Sandbox Code Playgroud)