Vuepress: TypeError: Cannot read property 'vue' of undefined

Created on 16 Apr 2018  ·  4Comments  ·  Source: vuejs/vuepress

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

ERROR in ./node_modules/[email protected]@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/[email protected]@vue-loader/lib/loader.js:61:18)
@ ./node_modules/[email protected]@vuepress/lib/app/app.js 6:0-32 47:13-21
@ ./node_modules/[email protected]@vuepress/lib/app/clientEntry.js
@ multi ./node_modules/[email protected]@vuepress/lib/app/clientEntry.js

ERROR in ./node_modules/[email protected]@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/[email protected]@vue-loader/lib/loader.js:61:18)
@ ./node_modules/[email protected]@vuepress/lib/app/.temp/routes.js 4:0-26 8:17-22
@ ./node_modules/[email protected]@vuepress/lib/app/app.js
@ ./node_modules/[email protected]@vuepress/lib/app/clientEntry.js
@ multi ./node_modules/[email protected]@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/[email protected]@vue-loader/lib/loader.js:61:18)
@ ./node_modules/[email protected]@vuepress/lib/app/.temp/routes.js 10:8-81
@ ./node_modules/[email protected]@vuepress/lib/app/app.js
@ ./node_modules/[email protected]@vuepress/lib/app/clientEntry.js
@ multi ./node_modules/[email protected]@vuepress/lib/app/clientEntry.js

bug

Most helpful comment

首先,需要提醒你的是,你在一个已经包含了 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

参考:https://github.com/vuejs/vue-loader/issues/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: https://github.com/vuejs/vue-loader/issues/1177

All 4 comments

我也是

首先,需要提醒你的是,你在一个已经包含了 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

参考:https://github.com/vuejs/vue-loader/issues/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: https://github.com/vuejs/vue-loader/issues/1177

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zeke picture zeke  ·  3Comments

lileiseven picture lileiseven  ·  3Comments

genedronek picture genedronek  ·  3Comments

kid1412621 picture kid1412621  ·  3Comments

cfjedimaster picture cfjedimaster  ·  3Comments