webpack打包报错[webpack-cli] ReferenceError: path is not defined

[webpack-cli] Failed to load 'D:\VScode Project\vue\change-rows-color\webpack.config.js' config
[webpack-cli] ReferenceError: path is not defined
    at Object. (D:\VScode Project\vue\change-rows-color\webpack.config.js:6:12)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at WebpackCLI.tryRequireThenImport (D:\VScode Project\vue\change-rows-color\node_modules\webpack-cli\lib\webpack-cli.js:244:16)
    at loadConfigByPath (D:\VScode Project\vue\change-rows-color\node_modules\webpack-cli\lib\webpack-cli.js:1712:30)
    at WebpackCLI.loadConfig (D:\VScode Project\vue\change-rows-color\node_modules\webpack-cli\lib\webpack-cli.js:1832:36)

在webpack.config.js文件最顶部没有引入path,添加上以下代码即可

const path = require("path");

你可能感兴趣的:(javascript,webpack,vue.js)