co-kevin / vue-cli-plugin-vux

Quick setup vux to your project - Vue CLI 3.0 plugin
MIT License
19 stars 0 forks source link

在已有的项目安装怎么使用呢? #6

Closed Akira0705 closed 5 years ago

Akira0705 commented 5 years ago

执行 npm i vue-cli-plugin-vux 后 需要在vue.config.js里面添加新配置嘛?

co-kevin commented 5 years ago

使用前请提交已修改的文件,保持工作区是干净的。不需要运行 npm i vue-cli-plugin-vux,直接运行下面的命令会自动安装 npm 依赖,创建 vue.config.js。

$ vue add vux
Akira0705 commented 5 years ago

执行 vue add vux 后报如下错误 `PS D:\LDKJ\travelone-yix-v2\trunk> vue add vux

📦 Installing vue-cli-plugin-vux...

co-kevin commented 5 years ago

可能你改了 App.vue 的路径。安装 vux 需要往 src/App.vue 写入代码。

可以手动往 App.vue 写入以完成安装,或者还原至 Vue CLI3 默认的目录结构重试:

<style lang="less">
@import '~vux/src/styles/reset.less';
</style>
Akira0705 commented 5 years ago

我手动添加了下 // App.vue `

`

然后执行 vue add vux 报错: `📦 Installing vue-cli-plugin-vux...

🚀 Invoking generator for vue-cli-plugin-vux... ERROR Error: EPERM: operation not permitted, open 'D:\LDKJ\travelone-yix-v2\trunk.svn\pristine\01\0100b53a161149a0182a77fb83209165f3a23e92.svn-base' Error: EPERM: operation not permitted, open 'D:\LDKJ\travelone-yix-v2\trunk.svn\pristine\01\0100b53a161149a0182a77fb83209165f3a23e92.svn-base' at Object.openSync (fs.js:443:3) at Object.writeFileSync (fs.js:1163:35) at Object.keys.forEach (C:\Users\ADMIN\AppData\Roaming\npm\node_modules\@vue\cli\lib\util\writeFileTree.js:25:8) at Array.forEach () at writeFileTree (C:\Users\ADMIN\AppData\Roaming\npm\node_modules\@vue\cli\lib\util\writeFileTree.js:22:22)`

运行npm run serve,报如下错: 10% building 1/1 modules 0 active(node:3376) DeprecationWarning: Tapable.plugin is deprecated. Use new API on .hooks instead 12% building 22/24 modules 2 active ...dules\html-entities\lib\xml-entities.js ERROR Failed to compile with 1 errors09:37:06

This relative module was not found:

Akira0705 commented 5 years ago

貌似是我的svn的问题?

co-kevin commented 5 years ago

可以尝试用 Vue CLI3 初始化一个新的项目,在这个新的项目上安装 vux;安装好后用 svn或git 对比一下文件差异,手动移植到当前项目来

Akira0705 commented 5 years ago

+ vue-cli-plugin-vux@3.0.0 updated 1 package and audited 20485 packages in 8.801s found 6 vulnerabilities (5 moderate, 1 high) runnpm audit fixto fix them, ornpm audit` for details ✔ Successfully installed plugin: vue-cli-plugin-vux

🚀 Invoking generator for vue-cli-plugin-vux... ✔ Successfully invoked generator for plugin: vue-cli-plugin-vux`

这应该算是安装成功了啪QAQ

然后npm run 起来又报错了(崩溃): `$ vue-cli-service serve --mode development --dashboard INFO Starting development server...

10% building 1/1 modules 0 active(node:21252) DeprecationWarning: Tapable.plugin is deprecated. Use new API on .hooks instead 12% building 18/22 modules 4 active ...\node_modules\webpack\buildin\module.js 81% module reviving RecordIdsPlugin ERROR Failed to compile with 1 errors10:06:13

This relative module was not found:

co-kevin commented 5 years ago

看下 src/main.js

Akira0705 commented 5 years ago

原来是把vue.config.js文件替换了,没注意到... 然后现在我引入vux后运行 还是报的插件安装之前的错误:

 error  in ./node_modules/vux/src/components/v-chart/v-point.vue

Module parse failed: Unexpected token (3:0)
You may need an appropriate loader to handle this file type.
| var render, staticRenderFns
| import script from "./v-point.vue?vue&type=script&lang=js&"
> ../../../../vux-loader/src/script-loader.js!export * from "./v-point.vue?vue&type=script&lang=js&"
| 
| 

 @ ./node_modules/vux/index.js 144:0-57 166:0-327:1
 @ ./src/business/plugins/vux.js
 @ ./src/business/main.js
 @ multi (webpack)-dev-server/client?http://192.168.10.113:8080/sockjs-node (webpack)/hot/dev-server.js ./src/business/main.js

 error  in ./node_modules/vux/src/components/v-chart/v-scale.vue

Module parse failed: Unexpected token (3:0)
You may need an appropriate loader to handle this file type.
| var render, staticRenderFns
| import script from "./v-scale.vue?vue&type=script&lang=js&"
> ../../../../vux-loader/src/script-loader.js!export * from "./v-scale.vue?vue&type=script&lang=js&"
| 
| 

 @ ./node_modules/vux/index.js 145:0-57 166:0-327:1
 @ ./src/business/plugins/vux.js
 @ ./src/business/main.js
 @ multi (webpack)-dev-server/client?http://192.168.10.113:8080/sockjs-node (webpack)/hot/dev-server.js ./src/business/main.js

(部分错误,每个vux的组件都报这个错)

各包ver: vue-cli:3.4.1 vue-loader:15.6.4 vux-loader:1.2.9

co-kevin commented 5 years ago

这个是由于 vux 中 export 和 module.export 混用导致的,webpack4不支持混用,我之前提了一个 PR https://github.com/airyland/vux/pull/3098 作者也没合并,你自己看看吧,如果需要的话就安装这个分支的代码

总之在 Vue CLI3 里用 vux 是有很多问题的,作者现在也不维护了,我也慢慢放弃 vux 了