【问题标题】:How to tell grunt to look for modules in the local node_modules?如何告诉 grunt 在本地 node_modules 中查找模块?
【发布时间】:2014-07-31 16:59:45
【问题描述】:

我尝试运行compass 任务:

» grunt compass:dist
Running "compass:dist" (compass) task
rbenv: compass: command not found

The `compass' command exists in these Ruby versions:
  1.9.3-p448

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

Aborted due to warnings.

指的是这个:

» rbenv versions
  system
  1.9.3-p448
* 2.1.0 (set by ..../app/.ruby-version)

但是谁在乎 ruby​​ 的安装呢? compass 模块已安装,在我的 app/node_modules 本地

» npm list | head
app-settings@0.0.0 .../app
├── compass@0.1.0
├── ember-template-compiler@1.6.1
├─┬ grunt@0.4.2
│ ├── async@0.1.22
│ ├── coffee-script@1.3.3

我有几个问题:

  1. 何时从 ruby​​ 安装中获取模块,何时从本地 node_modules 获取?
  2. 如何解决我的问题,并告诉 grunt 指南针模块确实已安装在 node_modules 中?

【问题讨论】:

    标签: ruby gruntjs npm


    【解决方案1】:

    这混淆了全局 rubygems 与本地的。正确的做法是:

    rbenv local 2.1.0   # DO THIS FIRST: select the ruby version to use
    gem install compass # install the gems with the selected ruby version
    rbenv rehash        # recompute all shims for ruby / gems
    

    现在你可以验证了:

    rbenv versions
    ruby --version
    compass --version
    which ruby
    which compass
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-09
      • 2016-04-15
      • 2018-03-13
      • 2011-02-08
      • 2016-09-29
      • 1970-01-01
      • 1970-01-01
      • 2019-01-29
      相关资源
      最近更新 更多