我有一个运行 Rails 5.2.1 和 Ruby 2.5.1 的 Rails 应用程序。当我运行 Rails 服务器时,出现以下错误:
Autoprefixer doesn’t support Node v4.8.2. Update it.
当我转到控制台检查我安装的 Node 版本时,使用 node -v
我得到:
v10.11.0
当我输入 nvm ls
时,我得到:
default -> node (-> v10.11.0)
node -> stable (-> v10.11.0) (default)
stable -> 10.11 (-> v10.11.0) (default)
iojs -> N/A (default)
lts/* -> lts/carbon (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.14.4 (-> N/A)
lts/carbon -> v8.12.0 (-> N/A)
我看过 Stackoverflow 上的其他答案,大多数都提到了 therubyracer gem,但我没有为这个应用程序安装那个 gem。这个版本的 Node 可以隐藏在哪里,我该如何删除它?
最佳答案
您需要更新安装的 Node.js 版本。
此问题已在此处解决:https://github.com/ai/autoprefixer-rails/issues/144
如果您通过 NPM 安装了 Node.js和您的操作系统包管理器(例如 apt
、dnf
、yum
或 pacman
),然后删除操作系统包管理器安装的版本。
# Using apt on Debian or Ubuntu based Linux distributions
sudo apt remove nodejs
如果您使用的是最新版本的 Debian 或 Ubuntu,您可以像这样安装 Node.js
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
如果使用 Ruby Docker container在安装 nodejs 包之前添加以下内容。请注意,我们没有在容器中使用 sudo
。
curl -sL https://deb.nodesource.com/setup_10.x | bash -
可以在此处找到有关安装和更新 Node.js 的更多信息: https://nodejs.org/en/download/package-manager
关于ruby-on-rails - Autoprefixer 不支持 Node v4.8.2。更新它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52708521/