我无法在我的 Rails 应用程序中创建 manifest.json

Posted

技术标签:

【中文标题】我无法在我的 Rails 应用程序中创建 manifest.json【英文标题】:I cannot create a manifest.json in my Rails app 【发布时间】:2021-05-10 23:36:59 【问题描述】:

我正在尝试从 TheOdinProject 启动一个示例 Rails 应用程序。它只创建一个应用程序,为汽车创建一个表,然后迁移它。在 localhost 中运行应用程序时,它显示 Webpacker::Manifest::MissingEntryError。 看起来在启动应用程序时 manifest.json 没有被创建。我从互联网上尝试了不同的解决方案,包括从头开始删除和重新安装 node_modules、实现处理测试的方法等等。

   
     "name": "foo",
     "private": true,
     "dependencies": 
       "@rails/actioncable": "^6.0.0",
       "@rails/activestorage": "^6.0.0",
       "@rails/ujs": "^6.0.0",
       "turbolinks": "^5.2.0"
    ,
    "version": "0.1.0",
    "devDependencies": 
      "webpack-dev-server": "^3.11.2"
    
  

这是我的 package.json。我注意到它没有“@rails/webpacker”作为依赖项。 希望您能够帮助我。 这是我的 Gemfile:

source 'https://rubygems.org'
git_source(:github)  |repo| "https://github.com/#repo.git" 

ruby '2.7.2'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.1.1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.4'
# Use Puma as the app server
gem 'puma', '~> 5.0'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Transpile app-like javascript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 5.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Active Storage variant
# gem 'image_processing', '~> 1.2'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.4', require: false

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 4.1.0'
  # Display performance information such as SQL time and flame graphs for each request in your browser.
  # Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md
  gem 'rack-mini-profiler', '~> 2.0'
  gem 'listen', '~> 3.3'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

group :test do
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 3.26'
  gem 'selenium-webdriver'
  # Easy installation and use of web drivers to run system tests with browsers
  gem 'webdrivers'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

【问题讨论】:

【参考方案1】:

我发现了问题。这是我的节点版本。我使用的是最新的,但不是 LTS,所以没有安装一些像 node-sass 这样的包。我降级了,现在一切正常。

【讨论】:

以上是关于我无法在我的 Rails 应用程序中创建 manifest.json的主要内容,如果未能解决你的问题,请参考以下文章

在 Rails 中创建对象及其所有关联模型的副本

Ruby on Rails Goal 有-many Steps 关联。如何为目标创建步骤?

在One2many字段中创建的数据也可用作其他模块上的数据

在 Rails 应用程序的其他数据库中创建数据

在 Rails / Freemium 中创建收费服务

如何在 RSpec (rails) 中创建或指定关联?