doubleyong
管理员
管理员
  • 最后登录2026-05-25
  • 发帖数1198
  • 最爱沙发
  • 喜欢达人
  • 原创写手
  • 社区居民
  • 忠实会员
阅读:8905回复:0

[其它]webpack error :The provided value "./dist" is not an absolute path!

楼主#
更多 发布于:2019-07-01 21:59
代码;
output:{
       path:'./dist'
       filename:'index.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!
       -> The output directory as **absolute path** (required).



原因:输出的路径需要时绝对路径

解决方案:
    方案一:使用__dirname表示当前文件的绝对路径  这个东西是node自带的
output:{
    path:__dirname+'/dist',
    filename:'index.js'
},


 方案二:node自带了一个处理路径的模块
const path=require('path');
output:{
     path:path.resolve(__dirname,'dist'),
    filename:'index.js'
},

参考:http://ke.gxaedu.com/course/186
知识需要管理,知识需要分享
游客


返回顶部

公众号

公众号