uni-app mac上Hbuilder编译失败,但命令行成功
uni-app mac上Hbuilder编译失败,但命令行成功
开发环境 | 版本号 | 项目创建方式 |
---|---|---|
Mac | MAC 10.15.5 | HBuilderX |
产品分类:uniapp/App
PC开发环境操作系统:Mac
HBuilderX类型:正式
HBuilderX版本号:3.1.2
手机系统:全部
手机厂商:华为
页面类型:vue
打包方式:云端
测试过的手机:全部
示例代码:
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
10:53:58.311 Error: Missing binding /Users/zhoub/vue-boce/boce-mall-H5/node_modules/node-sass/vendor/darwin-x64-57/binding.node
10:53:58.312 Node Sass could not find a binding for your current environment: OS X 64-bit with Node.js 8.x
10:53:58.317 Found bindings for the following environments:
10:53:58.317 - OS X 64-bit with Node.js 14.x
10:53:58.323 This usually happens because your environment has changed since running `npm install`.
10:53:58.323 Run `npm rebuild node-sass` to download the binding for your current environment.
10:53:58.331 at module.exports (/Users/zhoub/vue-boce/boce-mall-H5/node_modules/node-sass/lib/binding.js:15:13)
10:53:58.331 at Object.<anonymous> (/Users/zhoub/vue-boce/boce-mall-H5/node_modules/node-sass/lib/index.js:13:35)
操作步骤:
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
10:53:58.311 Error: Missing binding /Users/zhoub/vue-boce/boce-mall-H5/node_modules/node-sass/vendor/darwin-x64-57/binding.node
10:53:58.312 Node Sass could not find a binding for your current environment: OS X 64-bit with Node.js 8.x
10:53:58.317 Found bindings for the following environments:
10:53:58.317 - OS X 64-bit with Node.js 14.x
10:53:58.323 This usually happens because your environment has changed since running `npm install`.
10:53:58.323 Run `npm rebuild node-sass` to download the binding for your current environment.
10:53:58.331 at module.exports (/Users/zhoub/vue-boce/boce-mall-H5/node_modules/node-sass/lib/binding.js:15:13)
10:53:58.331 at Object.<anonymous> (/Users/zhoub/vue-boce/boce-mall-H5/node_modules/node-sass/lib/index.js:13:35)
预期结果:
编译成功
实际结果:
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
10:53:58.311 Error: Missing binding /Users/zhoub/vue-boce/boce-mall-H5/node_modules/node-sass/vendor/darwin-x64-57/binding.node
10:53:58.312 Node Sass could not find a binding for your current environment: OS X 64-bit with Node.js 8.x
10:53:58.317 Found bindings for the following environments:
10:53:58.317 - OS X 64-bit with Node.js 14.x
10:53:58.323 This usually happens because your environment has changed since running `npm install`.
10:53:58.323 Run `npm rebuild node-sass` to download the binding for your current environment.
10:53:58.331 at module.exports (/Users/zhoub/vue-boce/boce-mall-H5/node_modules/node-sass/lib/binding.js:15:13)
10:53:58.331 at Object.<anonymous> (/Users/zhoub/vue-boce/boce-mall-H5/node_modules/node-sass/lib/index.js:13:35)
bug描述:
在windows中可以编译成功,在mac时使用命令行npm run serve 是成功的,但是在HBUILDER时编译失败,报这个错,降低sass-loader版本也无效,
更多关于uni-app mac上Hbuilder编译失败,但命令行成功的实战教程也可以访问 https://www.itying.com/category-93-b0.html
3 回复
原因:您的uniapp-cli项目是用nodejs 14.x创建的,但是HBuilderX内置的nodejs 是8.x版本的。
解决方法:
卸载删除项目中的node-sass
终端执行: cd /Users/zhoub/vue-boce/boce-mall-H5 && /Applications/HBuilderX.app/Contents/HBuilderX/plugins/npm/npm install --save node-sass
更多关于uni-app mac上Hbuilder编译失败,但命令行成功的实战教程也可以访问 https://www.itying.com/category-93-b0.html
从错误信息来看,这是node-sass绑定问题导致的编译失败。问题核心在于HBuilderX内置的Node.js版本(8.x)与项目依赖的node-sass版本不兼容。
解决方案:
- 在项目根目录执行:
npm rebuild node-sass --force
- 如果问题依旧,建议改用dart-sass替代node-sass:
npm uninstall node-sass
npm install sass --save-dev