eslint时,发生这种错误。
代码语言:javascript复制 ERROR Error loading vue.config.js:
ERROR TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
at assertPath (path.js:39:11)
at Object.resolve (path.js:168:7)
at getOutputPath (D:nodejsprojectvuevue-tipvue.config.js:22:21)
at Object.<anonymous> (D:nodejsprojectvuevue-tipvue.config.js:38:16)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
相关代码是这一行
代码语言:javascript复制path.resolve(__dirname, 'dist', process.env.VUE_APP_DIR, 'static')
搜了一大堆,,貌似很多人答不在点上,网上抄袭严重。。。。
想了下,应该是 认不出 process.env.VUE_APP_DIR,这个是运行时才有的,eslint可能查不出来,,
解决办法:
代码语言:javascript复制As of Node v6.0.0 undefined as an argument to various path methods won't do. It has to be an (empty) string (nodejs/node#5348).
Probably a loader you're using is erring on this (there are bug reports concerning this issue all over the place..) (Thus) solution: make sure that instead of undefined an empty string is passed.
加一个兜底空字符串,如下,即可。
代码语言:javascript复制path.resolve(__dirname, 'dist', process.env.VUE_APP_DIR || '', 'static')