问答详情
源自:2-1 vue-loader+webpack项目配置

dirname is not defined

ReferenceError: _dirname is not defined

    at Object.<anonymous> (C:\Users\lianghuiling\Desktop\Intelligent school campus\newitem\webpack.config.js:5:22)

    at Module._compile (C:\Users\lianghuiling\Desktop\Intelligent school campus\newitem\node_modules\v8-compile-cache\v8-compile-cache.js:178:30)

    at Object.Module._extensions..js (module.js:654:10)

    at Module.load (module.js:556:32)

    at tryModuleLoad (module.js:499:12)

    at Function.Module._load (module.js:491:3)

    at Module.require (module.js:587:17)

    at require (C:\Users\lianghuiling\Desktop\Intelligent school campus\newitem\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)

    at WEBPACK_OPTIONS (C:\Users\lianghuiling\Desktop\Intelligent school campus\newitem\node_modules\webpack-cli\bin\convert-argv.js:133:13)

    at requireConfig (C:\Users\lianghuiling\Desktop\Intelligent school campus\newitem\node_modules\webpack-cli\bin\convert-argv.js:135:6)

    at C:\Users\lianghuiling\Desktop\Intelligent school campus\newitem\node_modules\webpack-cli\bin\convert-argv.js:142:17

    at Array.forEach (<anonymous>)

    at module.exports (C:\Users\lianghuiling\Desktop\Intelligent school campus\newitem\node_modules\webpack-cli\bin\convert-argv.js:140:15)

    at yargs.parse (C:\Users\lianghuiling\Desktop\Intelligent school campus\newitem\node_modules\webpack-cli\bin\webpack.js:240:39)

    at Object.parse (C:\Users\lianghuiling\Desktop\Intelligent school campus\newitem\node_modules\yargs\yargs.js:552:18)

    at C:\Users\lianghuiling\Desktop\Intelligent school campus\newitem\node_modules\webpack-cli\bin\webpack.js:218:8

    at Object.<anonymous> (C:\Users\lianghuiling\Desktop\Intelligent school campus\newitem\node_modules\webpack-cli\bin\webpack.js:515:3)

    at Module._compile (module.js:643:30)

    at Object.Module._extensions..js (module.js:654:10)

    at Module.load (module.js:556:32)

    at tryModuleLoad (module.js:499:12)

    at Function.Module._load (module.js:491:3)

    at Module.require (module.js:587:17)

    at require (internal/module.js:11:18)

    at Object.<anonymous> (C:\Users\lianghuiling\Desktop\Intelligent school campus\newitem\node_modules\webpack\bin\webpack.js:80:2)

    at Module._compile (module.js:643:30)

    at Object.Module._extensions..js (module.js:654:10)

    at Module.load (module.js:556:32)

    at tryModuleLoad (module.js:499:12)

    at Function.Module._load (module.js:491:3)

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! newitem@1.0.0 build: `webpack --config webpack.config.js`

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the newitem@1.0.0 build script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.


npm ERR! A complete log of this run can be found in:

npm ERR!     C:\Users\lianghuiling\AppData\Roaming\npm-cache\_logs\2018-05-24T14_29_22_106Z-debug.log


提问者:qq_蔷薇_4 2018-05-24 22:31

个回答

  • _蛰伏
    2018-05-25 11:13:58
    已采纳

    __dirname 是一个全部变量,是两个下划线的

  • qq_远得要命的爱情_1
    2018-05-27 09:26:37

    各位同学,如果想要走一个 和老师讲解流程,尽量少出现错误,除了老师敲得代码外,要注意:老师 nmp i  后面安装成功后的版本号,这个一致了,就没有问题