系统: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
我也是
首先,需要提醒你的是,你在一个已经包含了 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。
@ZhuLiangT 你解决了吗?怎么解决的?
将vue-loader更新到新的稳定版本就可以了
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
VuePressin a project that has alreadyWebpack, becauseVuePresshas a built-inWebpack. e.g. when your project has some some outdatedwebpack loaders, NPM will download the lowest version by default, which may cause some problems.Exactly, the
vue-loaderversion that VuePress uses is@15.0.0-rc.1, while latest webpack-simple uses@13.0.5, and14.0.0has some breaking change: https://github.com/vuejs/vue-loader/releases/tag/v14.0.0.Try to upgrade your
vue-loaderto the latest stable version:yarn add vue-loader@latest。See: https://github.com/vuejs/vue-loader/issues/1177