LoginSignup
15
8

More than 5 years have passed since last update.

Webpackで is not an absolute path! エラーの回避

Posted at

問題

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!

./dist 『それ絶対パスじゃないよ!』
そう言われても、絶対パス書いちゃうとあとで不便するし…

解決策

webpack.config.js 内で、現在パスを表す ${__dirname} を記載するとなんとかなるかも

webpack.config.js
module.exports = {
  output: {
    filename: '[name].js',
    path: `${__dirname}/dist` // バッククォート( ` )で囲ってね
  },

以上、ご報告でした。

15
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
8