Skip to content

TypeError: Received an unexpected value [object Undefined] #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jshuhao opened this issue Apr 17, 2020 · 21 comments
Closed

TypeError: Received an unexpected value [object Undefined] #17

jshuhao opened this issue Apr 17, 2020 · 21 comments

Comments

@jshuhao
Copy link

jshuhao commented Apr 17, 2020

vue cli 4.3.1创建的项目,vue add vue-next后报错, TypeError: Received an unexpected value [object Undefined]

@haoqunjiang
Copy link
Member

什么样的项目?能提供复现吗?

@baojie223
Copy link

@sodatea
node: 12.16.1
vue/cli: 4.3.1
这种情况下用cli新建一个vue项目,再vue add vue-next,就会遇到这个问题
image

@jshuhao
Copy link
Author

jshuhao commented Apr 17, 2020

就是正常用vue cli创建的项目,我随手创建的,准备想在cli里面试下vue3的功能,选了一些常用的配置,然后vue add vue-next后报错,项目也跑不起来。

@baojie223
Copy link

image
都是常用配置,并且根据vue-cli-plugin-vue-next里面所说的,没有添加typescript和test/utils

@haoqunjiang
Copy link
Member

haoqunjiang commented Apr 17, 2020

我猜是转换 router 代码时报的错?

那样的话可能跟这个 bug 有关 benjamn/ast-types#365 (comment)
因为 ast-types 已经是嵌套很深的依赖了,恐怕需要你们删除 @vue/cli、彻底清掉全局的 npm/yarn 缓存(npm cache clean -f 或者 yarn cache clean)再重装 @vue/cli 才能让这个修复生效。

我之前测的时候碰到过,后来强制指定 babylon 解析了理论上应该没问题了的……
现在我缓存也清掉了暂时没办法复现这个问题了。

@JZLeung
Copy link

JZLeung commented Apr 17, 2020

在全新的空项目(没有vuex没有router)上可以成功创建。
image

@baojie223
Copy link

照着你的操作做了,还是这个问题。。。。

@haoqunjiang
Copy link
Member

暂时无法复现问题。

问题实在无法解决的话,可以先把 router/index.js 里的 component: () => import(/* webpackChunkName: "about" */ "../views/About.vue") 这一行注释掉再运行 vue add vue-next 试试

@jshuhao
Copy link
Author

jshuhao commented Apr 17, 2020

@sodatea 刚才试了下,注释了好像还是不行,前面用了@JZLeung这个老哥的方法,不装vue-router和vuex没有报错
pic3

pic1
pic2

@wangjieCode
Copy link

去掉router,vuex运行成功

@jshuhao
Copy link
Author

jshuhao commented Apr 17, 2020

@wangjieCode 运行成功后您那边能使用vue新特性setup函数吗? 我这边试了好像不行。

@wangjieCode
Copy link

@wangjieCode 运行成功后您那边能使用vue新特性setup函数吗? 我这边试了好像不行。

可以的

@wangjieCode
Copy link

image

@JZLeung
Copy link

JZLeung commented Apr 17, 2020

@wangjieCode 运行成功后您那边能使用vue新特性setup函数吗? 我这边试了好像不行。

完全没毛病
image

@jshuhao
Copy link
Author

jshuhao commented Apr 17, 2020

@wangjieCode @JZLeung 感谢,刚才用错方法了。

@haoqunjiang
Copy link
Member

😂找到原因了,Windows 下的路径原因。这得在 @vue/cli 里修

@haoqunjiang
Copy link
Member

思考了下,还是在插件里直接做兼容了

@wossig
Copy link

wossig commented May 13, 2020

我现在任然碰到这个问题,有人能看看吗?

image

image

vue-cli-plugin-vue-next已经到0.1.2了
image

完整的 package.json

{
  "name": "deepbio.web.researcherdb",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "test:unit": "vue-cli-service test:unit",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "core-js": "^3.6.4",
    "vue": "^2.6.11",
    "vue-class-component": "^7.2.3",
    "vue-property-decorator": "^8.4.1",
    "vue-router": "^3.1.6"
  },
  "devDependencies": {
    "@types/jest": "^24.0.19",
    "@typescript-eslint/eslint-plugin": "^2.26.0",
    "@typescript-eslint/parser": "^2.26.0",
    "@vue/cli-plugin-babel": "~4.3.0",
    "@vue/cli-plugin-eslint": "~4.3.0",
    "@vue/cli-plugin-router": "~4.3.0",
    "@vue/cli-plugin-typescript": "~4.3.0",
    "@vue/cli-plugin-unit-jest": "~4.3.0",
    "@vue/cli-service": "~4.3.0",
    "@vue/eslint-config-standard": "^5.1.2",
    "@vue/eslint-config-typescript": "^5.0.2",
    "@vue/test-utils": "1.0.0-beta.31",
    "eslint": "^6.7.2",
    "eslint-plugin-import": "^2.20.2",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-promise": "^4.2.1",
    "eslint-plugin-standard": "^4.0.0",
    "eslint-plugin-vue": "^6.2.2",
    "less": "^3.0.4",
    "less-loader": "^5.0.0",
    "typescript": "~3.8.3",
    "vue-template-compiler": "^2.6.11"
  }
}

@haoqunjiang
Copy link
Member

TS 项目?暂时还不支持,如果有错是正常的

@haoqunjiang
Copy link
Member

"暂时还不支持" 指的是 generator 部分不支持。
装完后打包构建之类的没问题,但是你要手动改代码适配新版。

  • vue-class-component 要升到 v8
  • vue-property-decorator 暂时没发布支持 Vue 3 的新版本
  • 或者改用 defineComponent 写组件
  • 类型 shim 文件可能需要改,我还没确认过

@wossig
Copy link

wossig commented May 13, 2020

"暂时还不支持" 指的是 generator 部分不支持。
装完后打包构建之类的没问题,但是你要手动改代码适配新版。

  • vue-class-component 要升到 v8
  • vue-property-decorator 暂时没发布支持 Vue 3 的新版本
  • 或者改用 defineComponent 写组件
  • 类型 shim 文件可能需要改,我还没确认过

it's my fault, i forget to CD project directory(i should cd to project directory after VUE CREATE), and very appreciate your quick reply, hope typescript will be supported deeply!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants