Autoprefixer 不支持 Node v0.10.37 错误

Autoprefixer doesn’t support Node v0.10.37 error

在尝试 localhost:3000 时,它会抛出错误

ActionView::Template::Error (Autoprefixer doesn’t support Node v0.10.37. Update it.):

我已尝试更新节点,但没有可用的更新。

node -v # v8.1.3
nodejs -v # v0.10.37

宝石文件

gem 'bootstrap', '~> 4.1.3', and others

Gemfile.lock

autoprefixer-rails (9.1.1)

我遇到了类似的问题,通过将 gem 'mini_racer' 添加到您的 gemfile 中得到解决。

希望对您有所帮助!

我的问题是 autoprefixer 是作为另一个包的依赖安装的,但没有指定版本,所以安装的版本是 9.4.3,它有一个与我的本地节点安装冲突。

我通过在我的 GemFile 中为包添加特定版本来修复它,并且 运行 bundle install

gem 'autoprefixer-rails', '~> 7.1.6'

如果您刚刚构建了一个新的 rails 项目,请检查您的 Gemfile 是否包含

# gem 'mini_racer', platforms: :ruby

并取消注释。然后你应该

gem 'mini_racer', platforms: :ruby

运行 bundle update

这对我有用。就像卡尔提到的那样。

对我来说,错误是在 运行 SemaphoreCI.

时发现的

问题是 ExecJS(依赖项)有一种设置 Node 的方法会导致问题。问题出在Node初始化如下:

module ExecJS
  module Runtimes
    Node = ExternalRuntime.new(
      name:        "Node.js (V8)",
      command:     ["nodejs", "node"], # This line has the problem
      runner_path: ExecJS.root + "/support/node_runner.js",
      encoding:    'UTF-8'
    )
  end
end

所以我通过在 application.rb 文件的底部设置它来更改 Node 的初始化方式。

module ExecJS
  module Runtimes
    Node = ExternalRuntime.new(
      name:        "Node.js (V8)",
      command:     ["node", "nodejs"], # This is how to initialize Node
      runner_path: ExecJS.root + "/support/node_runner.js",
      encoding:    'UTF-8'
    )
  end
end

我 运行 遇到了这个问题,问题是我刚才从 运行dom 安装中得到了剩余的 nodejs 可执行文件。 看这里:https://github.com/twbs/bootstrap-rubygem/issues/162#issuecomment-440220624 我在终端 git rm -rf /usr/bin/nodejs

中删除了它

如果您正在使用 nvm,您可能需要将默认节点版本设置为更新的版本。

nvm install node # Install the latest available version

nvm alias default node # Always default to the latest available node version on a shell