无效的配置对象 output.path 不是绝对路径 [英] Invalid configuration object output.path is not an absolute path

查看:20
本文介绍了无效的配置对象 output.path 不是绝对路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用 webpack 将.ts"编译为.js",但出现此错误,我该如何解决?

I try compile ".ts" to ".js" with webpack but getting this error, how can I fix this?

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

推荐答案

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

output.path requires an absolute path, but you're giving it a relative path ./dist. You need to convert it to an absolute path, for instance by using path.resolve:

const path = require('path');

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

这篇关于无效的配置对象 output.path 不是绝对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆