Skip to content
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

TypeError: Cannot read property 'vue' of undefined #69

Closed
Leon1Zhu opened this issue Apr 16, 2018 · 4 comments
Closed

TypeError: Cannot read property 'vue' of undefined #69

Leon1Zhu opened this issue Apr 16, 2018 · 4 comments
Labels
type: bug Something isn't working

Comments

@Leon1Zhu
Copy link

系统:OSX 10.13.3
node版本:v9.10.1
新建的webpack-simple项目,按照官网安装依赖之后使用npx vuepress dev docs命令构建报错

ERROR in ./node_modules/_vuepress@0.4.0@vuepress/lib/default-theme/NotFound.vue
Module build failed: TypeError: Cannot read property 'vue' of undefined
at Object.module.exports (/Users/zhuliang/idea_workspace/myPro/tesetpress1/node_modules/_vue-loader@13.7.1@vue-loader/lib/loader.js:61:18)
@ ./node_modules/_vuepress@0.4.0@vuepress/lib/app/app.js 6:0-32 47:13-21
@ ./node_modules/_vuepress@0.4.0@vuepress/lib/app/clientEntry.js
@ multi ./node_modules/_vuepress@0.4.0@vuepress/lib/app/clientEntry.js

ERROR in ./node_modules/_vuepress@0.4.0@vuepress/lib/default-theme/Layout.vue
Module build failed: TypeError: Cannot read property 'vue' of undefined
at Object.module.exports (/Users/zhuliang/idea_workspace/myPro/tesetpress1/node_modules/_vue-loader@13.7.1@vue-loader/lib/loader.js:61:18)
@ ./node_modules/_vuepress@0.4.0@vuepress/lib/app/.temp/routes.js 4:0-26 8:17-22
@ ./node_modules/_vuepress@0.4.0@vuepress/lib/app/app.js
@ ./node_modules/_vuepress@0.4.0@vuepress/lib/app/clientEntry.js
@ multi ./node_modules/_vuepress@0.4.0@vuepress/lib/app/clientEntry.js

ERROR in ./docs/README.md
Module build failed: TypeError: Cannot read property 'vue' of undefined
at Object.module.exports (/Users/zhuliang/idea_workspace/myPro/tesetpress1/node_modules/_vue-loader@13.7.1@vue-loader/lib/loader.js:61:18)
@ ./node_modules/_vuepress@0.4.0@vuepress/lib/app/.temp/routes.js 10:8-81
@ ./node_modules/_vuepress@0.4.0@vuepress/lib/app/app.js
@ ./node_modules/_vuepress@0.4.0@vuepress/lib/app/clientEntry.js
@ multi ./node_modules/_vuepress@0.4.0@vuepress/lib/app/clientEntry.js

@fakaka
Copy link

fakaka commented Apr 16, 2018

我也是

@ulivz
Copy link
Member

ulivz commented Apr 16, 2018

首先,需要提醒你的是,你在一个已经包含了 webpack 的项目使用 VuePress 要尤为慎重,因为 VuePress 已经内置了 Webpack。比如,当你的项目中已经包含了某些 loader 的时候,npm 会默认下载最低的版本,这就可能出现问题。

恰好,VuePress 使用的 vue-loader 版本是 @15.0.0-rc.1,最新的 webpack-simple 使用的 vue-loader 版本则是 @13.0.5,而 14.0.0 的 vue-loader 又恰好有一些 breaking change:https://github.com/vuejs/vue-loader/releases/tag/v14.0.0。

尝试升级 vue-loader 到最新稳定版本:yarn add vue-loader@latest

参考:vuejs/vue-loader#1177


Above all, I want to remind you that you should be particularly careful about using VuePress in a project that has already Webpack, because VuePress has a built-in Webpack. e.g. when your project has some some outdated webpack loaders, NPM will download the lowest version by default, which may cause some problems.

Exactly, the vue-loader version that VuePress uses is @15.0.0-rc.1, while latest webpack-simple uses @13.0.5, and 14.0.0 has some breaking change: https://github.com/vuejs/vue-loader/releases/tag/v14.0.0.

Try to upgrade your vue-loader to the latest stable version: yarn add vue-loader@latest

See: vuejs/vue-loader#1177

@yyx990803 yyx990803 added the type: bug Something isn't working label Apr 16, 2018
@Leon1Zhu Leon1Zhu changed the title 显示vue未定义? TypeError: Cannot read property 'vue' of undefined Apr 16, 2018
@fakaka
Copy link

fakaka commented Apr 16, 2018

@ZhuLiangT 你解决了吗?怎么解决的?

@Leon1Zhu
Copy link
Author

将vue-loader更新到新的稳定版本就可以了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants