dcloudio / uni-app

A cross-platform framework using Vue.js
https://uniapp.dcloud.io
Apache License 2.0
40.15k stars 3.64k forks source link

HBuilderX 安装less插件后编译报错 #688

Closed SunnyEver0 closed 5 years ago

SunnyEver0 commented 5 years ago

问题描述 系统:MacOS HBuilder version:2.2.2.20190816 HBuilderX 安装less插件后运行微信小程序报错:

17:29:43.797 Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
17:29:43.797 ModuleBuildError: Module build failed (from ./node_modules/less-loader/dist/cjs.js):
17:29:43.808 Class constructor FileManager cannot be invoked without 'new'
17:29:43.815       in undefined (line undefined, column undefined)
17:29:43.826     at runLoaders (/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/webpack/lib/NormalModule.js:301:20)
17:29:43.827     at /Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/loader-runner/lib/LoaderRunner.js:367:11
17:29:43.843     at /Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/loader-runner/lib/LoaderRunner.js:233:18
17:29:43.844     at context.callback (/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
17:29:43.858     at <anonymous>
17:29:43.858     at runMicrotasksCallback (internal/process/next_tick.js:121:5)
17:29:43.875     at _combinedTickCallback (internal/process/next_tick.js:131:7)
17:29:43.876     at process._tickCallback (internal/process/next_tick.js:180:9)
17:29:43.925  ERROR  Build failed with errors.
fxy060608 commented 5 years ago

临时解决方案:到 HBuilderX.app/Contents/HBuilderX/plugins/compile-less 目录,删除 node_modules,修改 package.json 中的 less 依赖版本号,然后手动 npm install 一下

"dependencies": {
        "less": "3.9.0"
    },
fxy060608 commented 5 years ago

最新解决方案: 卸载重装 less 插件:HBuilderX->工具->插件安装-less编译->卸载-安装

SunnyEver0 commented 5 years ago

验证,已修复