如何解决“您需要在 PATH 中安装 Ruby 和 Sass 才能执行此任务”警告?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20176410/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 06:18:29  来源:igfitidea点击:

How to resolve "You need to have Ruby and Sass installed and in your PATH for this task to work" Warning?

rubymacosbashterminalsass

提问by Sven

I am in the process of setting up a new Mac for work. I have installed Grunt & Grunt CLI globally. Then I did a npm installinside a project folder to install all dependencies.

我正在设置新的 Mac 以进行工作。我已经在全球安装了 Grunt & Grunt CLI。然后我npm install在项目文件夹中做了一个来安装所有依赖项。

No problems so far, but as soon as I try to run the sass:disttask, I get this warning:

到目前为止没有问题,但是一旦我尝试运行该sass:dist任务,就会收到以下警告:

Warning: You need to have Ruby and Sass installed and in your PATH for
this task to work. More info:
https://github.com/gruntjs/grunt-contrib-sass Use --force 
to continue.

What I understand is that I need to have Ruby and Sass installed on a more global level for this task to run. As I am still pretty new to working with the terminal, I did a quick search to find out what PATHis - seems like its some system path (that can be changed) where important data is stored.

我的理解是,我需要在更全局的级别上安装 Ruby 和 Sass 才能运行此任务。由于我对使用终端仍然很陌生,因此我进行了快速搜索以找出是什么PATH- 似乎是存储重要数据的某些系统路径(可以更改)。

Does this mean I can simply do a sudo grunt install contrib-sass -gto resolve the issue? And what about Ruby – I always thought its already installed on OS X?

这是否意味着我可以简单地做一个sudo grunt install contrib-sass -g来解决问题?那么 Ruby 呢——我一直认为它已经安装在 OS X 上?

回答by Sven

Ok I got it. I just had to install Sass using gem install sassand now everything is fine...couldn't be easier.

好,我知道了。我只需要使用 Sass 安装gem install sass,现在一切都很好……再简单不过了。

回答by John Richard Salt

If you're on OSX El Capitan or Yosemite on Mac there seem to be an issue installing the gem.

如果您在 Mac 上使用 OSX El Capitan 或 Yosemite,则安装 gem 似乎存在问题。

Try

尝试

sudo gem install -n /usr/local/bin sass

Solution was from github.

解决方案来自 github

回答by Gaurav

You need to install Ruby and Sass as:

您需要将 Ruby 和 Sass 安装为:

For Ruby use command

对于 Ruby 使用命令

sudo apt-get install ruby-full

sudo apt-get install ruby-full

And for Sass use command

而对于 Sass 使用命令

sudo gem install sass

回答by Yogesh Sinoriya

grunt-sass documentation is not very clear. To avoid the need of Ruby, you can try this:

grunt-sass 文档不是很清楚。为了避免需要 Ruby,你可以试试这个:

npm uninstall --save grunt-contrib-sass
npm install --save node-sass grunt-sass

npm uninstall --save grunt-contrib-sass
npm install --save node-sass grunt-sass

Try this, It's work for me.

试试这个,它对我有用。

reference

参考

回答by Vaiden

Also simply brew install saas/sass/sasson Mac High Sierra (10.13.x)

也只是brew install saas/sass/sass在 Mac High Sierra (10.13.x) 上

回答by Ruwan Bandara

You need to install Ruby and Sass as:

您需要将 Ruby 和 Sass 安装为:

For Ruby use command

对于 Ruby 使用命令

sudo apt-get install ruby-full

And for Sass use command

而对于 Sass 使用命令

sudo gem install sass

回答by Rohit Katiyar

Use grunt --force if you are using grunt. If you want to run an application using grunt and a warning is occur like this. For ignoring this warning you can use --force.

如果您使用 grunt,请使用 grunt --force。如果您想使用 grunt 运行应用程序并且会出现这样的警告。要忽略此警告,您可以使用 --force。

回答by squarecandy

I used Homebrewto install Ruby and then Ruby to install SASS. Probably only the best way to do it if you already use Homebrew, or want to start using it regularly...

我使用Homebrew安装 Ruby,然后使用 Ruby 安装 SASS。如果您已经使用 Homebrew,或者想定期开始使用它,这可能只是最好的方法......

brew install ruby
gem install sass