简体   繁体   English

离子 - 无法开始吞咽

[英]Ionic - Can't start gulp

After running:运行后:

ionic setup sass

And installing all dependencies, when I try to start gulp , I have this error instead:并安装所有依赖项,当我尝试启动gulp ,出现此错误:

/Users/user/Sites/ionic/project/node_modules/gulp-sass/node_modules/node-sass/lib/index.js:22
    throw new Error('`libsass` bindings not found. Try reinstalling `node-sass`?');
    ^

Error: `libsass` bindings not found. Try reinstalling `node-sass`?

I'm trying to reinstall node-sass, but no success so far.我正在尝试重新安装 node-sass,但到目前为止没有成功。 Any idea on how to fix this issue?关于如何解决这个问题的任何想法?

Thanks!谢谢!

This workaround has fixed all.解决方法已解决所有问题。

Starting with this setup:从这个设置开始:

Cordova CLI: 5.3.3 Gulp version: CLI version 3.9.0 Gulp local: Local version 3.9.0 Ionic Version: 1.1.0 Ionic CLI Version: 1.6.5 Ionic App Lib Version: 0.3.9 ios-deploy version: Not installed ios-sim version: 5.0.1 OS: Mac OS X Yosemite Node Version: v4.1.1 Xcode version: Xcode 6.4 Build version 6E35b Cordova CLI:5.3.3 Gulp 版本:CLI 版本 3.9.0 Gulp local:本地版本 3.9.0 Ionic 版本:1.1.0 Ionic CLI 版本:1.6.5 Ionic App Lib 版本:0.3.9 ios-deploy 版本:未安装ios-sim 版本:5.0.1 操作系统:Mac OS X Yosemite Node 版本:v4.1.1 Xcode 版本:Xcode 6.4 Build version 6E35b

I've found a way to avoid to use 'sudo' command.我找到了一种避免使用“sudo”命令的方法。 We need before to fix npm permissions following this: https://docs.npmjs.com/getting-started/fixing-npm-permissions and fixing permissions for Node here: http://mawaha.com/permission-fix-node-js/ After this we can check and reinstall software without 'sudo' for npm, n or ionic.我们需要在此之前修复 npm 权限: https : //docs.npmjs.com/getting-started/fixing-npm-permissions并在此处修复节点的权限: http : //mawaha.com/permission-fix-node- js/在此之后,我们可以检查并重新安装软件,而无需为 npm、n 或 ionic 使用“sudo”。

I followed this step:我遵循了这一步:

npm install -g n
rm -R node_modules/ 
npm install node-sass@3.3.3 
npm -g install node-gyp@3
npm uninstall gulp-sass
npm install gulp-sass@2 
npm rebuild node-sass 
ionic setup sass 

Why node-sass@3.3.3?为什么是 node-sass@3.3.3? Because it works with latest ionic version: https://github.com/driftyco/ionic/pull/4449因为它适用于最新的离子版本: https : //github.com/driftyco/ionic/pull/4449

Are you on Node 4?您在节点 4 上吗? That's a somewhat common issue with the new C bindings.这是新的 C 绑定的一个常见问题。 Here's a solution that worked for a lot:这是一个很有效的解决方案:

 $ npm uninstall gulp-sass node-sass
 $ npm install node-sass@1.0.3
 $ npm install gulp-sass

I've just fixed problems with libsass or node-sass with this command:我刚刚使用以下命令修复了 libsass 或 node-sass 的问题:

$ sudo rm -rf node_modules/ && cat package.json | sed -i.bak 's/"gulp-sass": "^X.X.X"/"gulp-sass": "^2.0.4"/g' package.json && npm install && ionic lib update

Where X is the version of gulp-sass in your package.json其中 X 是 package.json 中 gulp-sass 的版本

Explanation:解释:

Remove the old files in node_modules.删除 node_modules 中的旧文件。 I'm not sure is necessary to use 'sudo' (in my case, yes).我不确定是否有必要使用“sudo”(在我的情况下,是的)。

$ sudo rm -rf node_modules/

Search and replace inside package.json updating gulp-sass version to ^2.0.4.在 package.json 中搜索并替换将 gulp-sass 版本更新为 ^2.0.4。 It also creates a backup (package.json.bak),它还创建一个备份(package.json.bak),

$ cat package.json | sed -i.bak 's/"gulp-sass": "^X.X.X"/"gulp-sass": "^2.0.4"/g' package.json

Reinstall dependencies重新安装依赖项

$ npm install

Update the ionic lib in the project更新项目中的ionic lib

ionic lib update

If you have any further problems be sure I try can help you...如果您有任何进一步的问题,请确保我尝试可以帮助您...

Bye再见

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM