webpack:未定义的变量

时间:2016-11-25 09:45:21

标签: webpack

我执行时遇到此问题:

webpack --config config/webpack.prod.js  --progress --profile --bail

它转储的邮件是:path is not defined

D:\projects\living\user-platform\project\config\webpack.prod.js:196
            resourcePath: path.resolve(projectRoot, appConfig.root)
                          ^
ReferenceError: path is not defined
    at module.exports (D:\projects\living\user-platform\project\config\webpack.prod.js:196:27)
    at requireConfig (C:\Users\Beep\AppData\Roaming\npm\node_modules\webpack\bin\convert-argv.js:104:15)
    at C:\Users\Beep\AppData\Roaming\npm\node_modules\webpack\bin\convert-argv.js:111:17
    at Array.forEach (native)
    at module.exports (C:\Users\Beep\AppData\Roaming\npm\node_modules\webpack\bin\convert-argv.js:109:15)
    at Object.<anonymous> (C:\Users\Beep\AppData\Roaming\npm\node_modules\webpack\bin\webpack.js:141:40)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:420:7)
    at startup (bootstrap_node.js:139:9)
    at bootstrap_node.js:535:3

这些是我的webpack配置文件:

1 个答案:

答案 0 :(得分:1)

似乎是一个简单的问题。你能尝试在顶部的某处添加它,看看是否一切正常:

var path = require('path');