skip to Main Content

My OS is Linux and my distribution is debian-bullseye. My ruby version is 3.1 and my rails version is 7.

I created a rails project

rails new chat --skip-javascript
cd chat/

I installed hotwire

bundle add hotwire-rails
rails hotwire:install

And I got this error

You must either be running with node (package.json) or importmap-rails (config/importmap.rb) to use this gem.

I am trying to follow this tutorial

2

Answers


  1. Chosen as BEST ANSWER

    it's just a demo, made back when rails 6 was a thing. rails 7 has it by default. rails new chat is all you need. it'll set up all the javascript for you. hotwire-rails is not a thing anymore. Alex


  2. you only need type this

    C:Usersapp>rails importmap:install
    

    press enter
    then you will see the code below..

    Add Importmap include tags in application layout
          insert  app/views/layouts/application.html.erb
    Create application.js module as entrypoint
          create  app/javascript/application.js
    Use vendor/javascript for downloaded pins
          create  vendor/javascript
          create  vendor/javascript/.keep
    Ensure JavaScript files are in the Sprocket manifest
          append  app/assets/config/manifest.js
    Configure importmap paths in config/importmap.rb
          create  config/importmap.rb
    Copying binstub
          create  bin/importmap
    

    after that type

    C:Usersapp>rails hotwire:install
    

    press enter
    you will see the code below

    Create controllers directory
          create  app/javascript/controllers
          create  app/javascript/controllers/index.js
          create  app/javascript/controllers/application.js
          create  app/javascript/controllers/hello_controller.js
    Import Stimulus controllers
          append  app/javascript/application.js
    Pin Stimulus
    Appending: pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true"
          append  config/importmap.rb
    Appending: pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true
          append  config/importmap.rb
    Pin all controllers
    Appending: pin_all_from "app/javascript/controllers", under: "controllers"
          append  config/importmap.rb
    Import Turbo
          append  app/javascript/application.js
    Pin Turbo
          append  config/importmap.rb
    Run turbo:install:redis to switch on Redis and use it in development for turbo streams
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search