【问题标题】:Issue with first Ruby On Rails application第一个 Ruby On Rails 应用程序的问题
【发布时间】:2019-10-29 21:42:43
【问题描述】:

我正在尝试启动我的第一个 Rails 应用程序,但它不工作。

我安装了 yarn 并检查了它是否已经安装。

然后我输入了rails webpacker:install。由于某种原因节点没有安装,我为节点输入了 post install ,它仍然没有工作。

对于一些背景知识,我有一台 2012 年中期的 Mac,操作系统为 Mojave 10.14.6 ,Ruby 版本 2.6.3 ,Ruby on rails 版本 6.0.0 和纱线版本 1.19.1

我的代码:

(base) Apples-MBP:~ apple$ cd desktop
(base) Apples-MBP:desktop apple$ cd portfolio
(base) Apples-MBP:portfolio apple$ rails s
=> Booting Puma
=> Rails 6.0.0 application starting in development 
=> Run `rails server --help` for more startup options
RAILS_ENV=development environment is not defined in config/webpacker.yml, falling back to production environment
Exiting
Traceback (most recent call last):

在此之后,我得到了一份文件和 gem 的列表,这些文件和 gem 可能太长而无法在此处发布。

我希望 Rails 确认它正在运行,以便我可以在 localhost:3000 上看到我的工作,但这是最终结果

/Users/apple/.rvm/gems/ruby-2.6.3/gems/webpacker-4.0.7/lib/webpacker/configuration.rb:91:in `rescue in load': Webpacker configuration file not found /Users/apple/Desktop/portfolio/config/webpacker.yml. Please run rails webpacker:install Error: No such file or directory @ rb_sysopen - /Users/apple/Desktop/portfolio/config/webpacker.yml (RuntimeError)
(base) Apples-MBP:portfolio apple$

任何帮助将不胜感激!

【问题讨论】:

  • 您应该在 config/webpacker.yml 中创建一个“开发”部分
  • rails s 错误表明Please run rails webpacker:install - 在服务器启动之前,您需要让它成功运行。您使用的是什么版本的节点,它是如何安装的?
  • 节点没有安装成功,即使我尝试了安装后命令。我将尝试单独安装节点,然后再次运行 rails webpacker install。

标签: ruby-on-rails command-line


【解决方案1】:

首先安装 brew 在终端中输入以下内容

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

然后安装 Yarn:

brew install yarn

或手动执行此操作:

curl -o- -L https://yarnpkg.com/install.sh | bash

现在运行命令:

yarn install
rails webpacker:install

【讨论】:

  • 我已经安装了 Homebrew,Rails 现在可以工作了,我需要做的就是重新安装它并单独安装 Yarn!感谢所有的答案。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-01-06
  • 2021-07-03
  • 2012-09-15
  • 2017-04-25
  • 2011-01-17
  • 2019-05-04
  • 1970-01-01
相关资源
最近更新 更多