Iain
Iain
  • 发布:2019-05-15 10:07
  • 更新:2019-05-17 16:35
  • 阅读:7311

【报Bug】vue-cli创建的uniapp项目,打包发行( yarn build:h5)H5手机版【失败】——【已解决】

分类:uni-app

【npm update】或【yarn upgrade 】更新依赖库,可解决该问题!!!

详细问题描述

按照官方教程使用脚手架创建uniapp项目,开发环境都正常能运行。打包发布H5版时报错

[内容]

重现步骤

PS I:\Workspace\uni-app>npm install -g @vue/cli  
PS I:\Workspace\uni-app> vue create -p dcloudio/uni-preset-vue cli-wen-lv-yun2  
✔  Fetching remote preset dcloudio/uni-preset-vue...  

Vue CLI v3.7.0  
✨  Creating project in I:\Workspace\uni-app\cli-wen-lv-yun2.  
�  Initializing git repository...  
⚙  Installing CLI plugins. This might take a while...  

yarn install v1.12.3  
info No lockfile found.  
[1/4] Resolving packages...  
[2/4] Fetching packages...  
info fsevents@1.2.9: The platform "win32" is incompatible with this module.  
info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.  
[3/4] Linking dependencies...  
[4/4] Building fresh packages...  
success Saved lockfile.  
Done in 26.89s.  
�  Invoking generators...  

Preset options:  
? 请选择 uni-app 模板 默认模板  
�  Installing additional dependencies...  

yarn install v1.12.3  
[1/4] Resolving packages...  
[2/4] Fetching packages...  
info fsevents@1.2.9: The platform "win32" is incompatible with this module.  
info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.  
[3/4] Linking dependencies...  
[4/4] Building fresh packages...  

success Saved lockfile.  
Done in 9.12s.  
⚓  Running completion hooks...  

�  Generating README.md...  

�  Successfully created project cli-wen-lv-yun2.  
�  Get started with the following commands:  

 $ cd cli-wen-lv-yun2  
 $ yarn serve  

I:\Workspace\uni-app\cli-wen-lv-yun2\cd cli-wen-lv-yun2  
I:\Workspace\uni-app\cli-wen-lv-yun2\yarn build:h5

[结果]

PS I:\Workspace\uni-app\cli-wen-lv-yun2> yarn build:h5
yarn run v1.12.3
$ cross-env NODE_ENV=production UNI_PLATFORM=h5 vue-cli-service uni-build

\ 开始编译当前项目至 h5 平台...

ERROR Failed to compile with 2 errors 09:52:37
error in ./src/App.vue?vue&type=script&lang=js&

Module build failed (from ./node_modules/thread-loader/dist/cjs.js):
Thread Loader (Worker 0)
compiler.parseComponent is not a function
at PoolWorker.fromErrorObj (I:\Workspace\uni-app\cli-wen-lv-yun2\node_modules\thread-loader\dist\WorkerPool.js:258:12)
at I:\Workspace\uni-app\cli-wen-lv-yun2\node_modules\thread-loader\dist\WorkerPool.js:200:29
at mapSeries (I:\Workspace\uni-app\cli-wen-lv-yun2\node_modules\neo-async\async.js:3625:14)
at PoolWorker.onWorkerMessage (I:\Workspace\uni-app\cli-wen-lv-yun2\node_modules\thread-loader\dist\WorkerPool.js:166:35)
at readBuffer (I:\Workspace\uni-app\cli-wen-lv-yun2\node_modules\thread-loader\dist\WorkerPool.js:148:14)
at Socket.onChunk (I:\Workspace\uni-app\cli-wen-lv-yun2\node_modules\thread-loader\dist\readBuffer.js:36:9)
at Socket.emit (events.js:182:13)
at parse (I:\Workspace\uni-app\cli-wen-lv-yun2\node_modules\@vue\component-compiler-utils\dist\parse.js:14:23)
at Object.module.exports (I:\Workspace\uni-app\cli-wen-lv-yun2\node_modules\vue-loader\lib\index.js:67:22)

@ ./src/App.vue?vue&type=script&lang=js& 1:0-668 1:684-687 1:689-1354 1:689-1354
@ ./src/App.vue
@ ./src/main.js
@ multi ./src/main.js

error in ./src/pages/index/index.vue?vue&type=script&lang=js&

Module build failed (from ./node_modules/thread-loader/dist/cjs.js):
Thread Loader (Worker 1)
compiler.parseComponent is not a function

at parse (I:\Workspace\uni-app\cli-wen-lv-yun2\node_modules\@vue\component-compiler-utils\dist\parse.js:14:23)  
at Object.module.exports (I:\Workspace\uni-app\cli-wen-lv-yun2\node_modules\vue-loader\lib\index.js:67:22)  

@ ./src/pages/index/index.vue?vue&type=script&lang=js& 1:0-672 1:688-691 1:693-1362 1:693-1362
@ ./src/pages/index/index.vue
@ ./src/pages.json
@ ./src/main.js
@ multi ./src/main.js

ERROR Build failed with errors.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

[期望]
正常编译后打包成H5

联系方式

[邮箱] znjmails@qq.com

2019-05-15 10:07 负责人:无 分享
已邀请:
DCloud_UNI_FXY

DCloud_UNI_FXY

npm update 更新最新的依赖库,可解决该问题

  • Iain (作者)

    Thanks♪(・ω・)ノ亲测,更新依赖库后,打包成功。

    2019-05-17 17:00

  • 3***@qq.com

    回复 Iain: npm update也报错,怎么处理,,

    2019-09-12 17:15

该问题目前已经被锁定, 无法添加新回复