Closed Akira0705 closed 5 years ago
使用前请提交已修改的文件,保持工作区是干净的。不需要运行 npm i vue-cli-plugin-vux
,直接运行下面的命令会自动安装 npm 依赖,创建 vue.config.js。
$ vue add vux
执行 vue add vux
后报如下错误
`PS D:\LDKJ\travelone-yix-v2\trunk> vue add vux
📦 Installing vue-cli-plugin-vux...
vue-cli-plugin-vux@3.0.0
updated 1 package and audited 20485 packages in 8.484s
found 6 vulnerabilities (5 moderate, 1 high)
run npm audit fix
to fix them, or npm audit
for details
✔ Successfully installed plugin: vue-cli-plugin-vux
ERROR Error: ENOENT: no such file or directory, open 'src/App.vue'
Error: ENOENT: no such file or directory, open 'src/App.vue'
at Object.openSync (fs.js:443:3)
at Object.readFileSync (fs.js:348:35)
at readAppVue (D:\LDKJ\travelone-yix-v2\trunk\node_modules\vue-cli-plugin-vux\generator.js:25:22)
at module.exports (D:\LDKJ\travelone-yix-v2\trunk\node_modules\vue-cli-plugin-vux\generator.js:4:25)
at Generator.plugins.forEach (C:\Users\ADMIN\AppData\Roaming\npm\node_modules\@vue\cli\lib\Generator.js:103:7)
at Array.forEach (
可能你改了 App.vue 的路径。安装 vux 需要往 src/App.vue 写入代码。
可以手动往 App.vue 写入以完成安装,或者还原至 Vue CLI3 默认的目录结构重试:
<style lang="less">
@import '~vux/src/styles/reset.less';
</style>
我手动添加了下 // App.vue `
`
然后执行 vue add vux 报错: `📦 Installing vue-cli-plugin-vux...
npm audit fix
to fix them, or npm audit
for details
✔ Successfully installed plugin: 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 (
运行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:
./src/main.js in multi (webpack)-dev-server/client?http://192.168.10.113:8080/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
WARN Couldn't parse bundle asset "D:\LDKJ\travelone-yix-v2\trunk\dist\app.js". Analyzer will use module sizes from stats file.
貌似是我的svn的问题?
可以尝试用 Vue CLI3 初始化一个新的项目,在这个新的项目上安装 vux;安装好后用 svn或git 对比一下文件差异,手动移植到当前项目来
+ vue-cli-plugin-vux@3.0.0 updated 1 package and audited 20485 packages in 8.801s found 6 vulnerabilities (5 moderate, 1 high) run
npm audit fixto fix them, or
npm 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:
./src/main.js in multi (webpack)-dev-server/client?http://192.168.10.113:8080/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
WARN Couldn't parse bundle asset "D:\LDKJ\travelone-yix-v2\trunk\dist\app.js". Analyzer will use module sizes from stats file. `
看下 src/main.js
原来是把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
这个是由于 vux 中 export 和 module.export 混用导致的,webpack4不支持混用,我之前提了一个 PR https://github.com/airyland/vux/pull/3098 作者也没合并,你自己看看吧,如果需要的话就安装这个分支的代码
总之在 Vue CLI3 里用 vux 是有很多问题的,作者现在也不维护了,我也慢慢放弃 vux 了
执行
npm i vue-cli-plugin-vux
后 需要在vue.config.js里面添加新配置嘛?