前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >The "path" argument must be of type string. Received type undefined

The "path" argument must be of type string. Received type undefined

原创
作者头像
shirishiyue
发布2019-04-17 21:20:17
19.7K0
发布2019-04-17 21:20:17
举报
文章被收录于专栏:全栈码全栈码

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:\nodejs\project\vue\vue-tip\vue.config.js:22:21)
    at Object.<anonymous> (D:\nodejs\project\vue\vue-tip\vue.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')

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档