0
$ bin/dev
22:48:36 web.1  | started with pid 6565
22:48:36 css.1  | started with pid 6566
22:48:42 web.1  | => Booting Puma
22:48:42 web.1  | => Rails 7.0.8 application starting in development 
22:48:42 web.1  | => Run `bin/rails server --help` for more startup options
22:48:43 css.1  | rails aborted!
22:48:43 css.1  | Don't know how to build task 'tailwindcss:watch' (See the list of available tasks with `rails --tasks`)
22:48:43 css.1  | 
22:48:43 css.1  | (See full trace by running task with --trace)
22:48:44 css.1  | exited with code 1
22:48:44 system | sending SIGTERM to all processes
22:48:44 web.1  | Exiting
22:48:44 web.1  | terminated by SIGTERM
$ rails --tasks
rails about                              # List versions of all Rails framework...
rails action_mailbox:ingress:exim        # Relay an inbound email from Exim to ...
rails action_mailbox:ingress:postfix     # Relay an inbound email from Postfix ...
rails action_mailbox:ingress:qmail       # Relay an inbound email from Qmail to...
rails action_mailbox:install             # Installs Action Mailbox and its depe...
rails action_mailbox:install:migrations  # Copy migrations from action_mailbox ...
rails action_text:install                # Copy over the migration, stylesheet,...
rails action_text:install:migrations     # Copy migrations from action_text to ...
rails active_storage:install             # Copy over the migration needed to th...
rails app:template                       # Applies the template supplied by LOC...
rails app:update                         # Update configs and some other initia...
rails assets:clean[keep]                 # Remove old compiled assets
rails assets:clobber                     # Remove compiled assets
rails assets:environment                 # Load asset compile environment
rails assets:precompile                  # Compile all the assets named in conf...
rails cache_digests:dependencies         # Lookup first-level dependencies for ...
rails cache_digests:nested_dependencies  # Lookup nested dependencies for TEMPL...
rails db:create                          # Creates the database from DATABASE_U...
rails db:drop                            # Drops the database from DATABASE_URL...
rails db:encryption:init                 # Generate a set of keys for configuri...
rails db:environment:set                 # Set the environment value for the da...
rails db:fixtures:load                   # Loads fixtures into the current envi...
rails db:migrate                         # Migrate the database (options: VERSI...
rails db:migrate:down                    # Runs the "down" for a given migratio...
rails db:migrate:redo                    # Rolls back the database one migratio...
rails db:migrate:status                  # Display status of migrations
rails db:migrate:up                      # Runs the "up" for a given migration ...
rails db:prepare                         # Runs setup if database does not exis...
rails db:reset                           # Drops and recreates all databases fr...
rails db:rollback                        # Rolls the schema back to the previou...
rails db:schema:cache:clear              # Clears a db/schema_cache.yml file
rails db:schema:cache:dump               # Creates a db/schema_cache.yml file
rails db:schema:dump                     # Creates a database schema file (eith...
rails db:schema:load                     # Loads a database schema file (either...
rails db:seed                            # Loads the seed data from db/seeds.rb
rails db:seed:replant                    # Truncates tables of each database fo...
rails db:setup                           # Creates all databases, loads all sch...
rails db:version                         # Retrieves the current schema version...
rails importmap:install                  # Setup Importmap for the app
rails log:clear                          # Truncates all/specified *.log files ...
rails middleware                         # Prints out your Rack middleware stack
rails restart                            # Restart app by touching tmp/restart.txt
rails secret                             # Generate a cryptographically secure ...
rails stats                              # Report code statistics (KLOCs, etc) ...
rails stimulus:install                   # Install Stimulus into the app
rails stimulus:install:importmap         # Install Stimulus on an app running i...
rails stimulus:install:node              # Install Stimulus on an app running node
rails test                               # Runs all tests in test folder except...
rails test:all                           # Runs all tests, including system tests
rails test:db                            # Run tests quickly, but also reset db
rails test:system                        # Run system tests only
rails time:zones[country_or_offset]      # List all time zones, list by two-let...
rails tmp:clear                          # Clear cache, socket and screenshot f...
rails tmp:create                         # Creates tmp directories for cache, s...
rails turbo:install                      # Install Turbo into the app
rails turbo:install:importmap            # Install Turbo into the app with asse...
rails turbo:install:node                 # Install Turbo into the app with webp...
rails turbo:install:redis                # Switch on Redis and use it in develo...
rails yarn:install                       # Install all JavaScript dependencies ...
rails zeitwerk:check                     # Checks project structure for Zeitwer...

↑こんな風にtailwindcssがないって言われますが、

 package.json

{
  "name": "app",
  "private": "true",
  "dependencies": {
    "@hotwired/stimulus": "^3.0.1",
    "@hotwired/turbo-rails": "^7.1.1",
    "@popperjs/core": "^2.11.4",
    "autoprefixer": "^10.4.15",
    "bootstrap": "^5.1.3",
    "bootstrap-icons": "^1.8.1",
    "esbuild": "^0.14.30",
    "postcss": "^8.4.29",
    "sass": "^1.49.11",
    "tailwindcss": "^3.3.3"
  },
  "scripts": {
    "build": "esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds",
    "build:css": "sass ./app/assets/stylesheets/application.bootstrap.scss ./app/assets/builds/application.css --no-source-map --load-path=node_modules",
    "tailwindcss:watch": "tailwindcss build -o app/assets/builds/application.css --watch"
  }
}

package.jsonにはちゃんと記述してあります。

一応tailwind.config.jsファイルの中身です。↓

    /** @type {import('tailwindcss').Config} */
module.exports = {
  content: ['./proj/netlibx/app/view/home/top.html'],
  theme: {
    extend: {},
  },
plugins: ["tailwindcss", "autoprefixer"],
}

node_modulesのtailwindcssファイルの中身

    #!/usr/bin/env node
"use strict";
if (false) {
    module.exports = require("./oxide/cli");
} else {
    module.exports = require("./cli/index");
}

何が問題ですか?
なんでtailwindcssタスクが存在してないことになってるんですか?

4
  • 1
    過去の質問も含めて、ソースコード等は画像キャプチャではなく文字のまま質問に貼り付けてください。
    – cubick
    Commented 2023年9月30日 8:15
  • なぜでしょうか、画像だと分かりにくいんですか?
    – Star
    Commented 2023年9月30日 9:54
  • 理由については以下の FAQ を参照してください。 スクショしたコードで質問して良いですか?
    – cubick
    Commented 2023年10月1日 6:30
  • なるほど理解しました。とりあえず貼り付けるので解決策をご協力をお願いします。 ja.stackoverflow.com/questions/96384/…
    – Star
    Commented 2023年10月1日 13:09

1 件の回答 1

1

Rails 7.0 で tailwindcss-rails gem を使おうとなさっているという前提で回答を書きます。

まず、Don't know how to build task 'tailwindcss:watch' で言われている tailwindcss:watch task とは、Rake task の tailwindcss:watch です。package.json で定義されている scripts ではありません。

bin/dev で起動してらっしゃるのでおそらく Procfile.devcss: bin/rails tailwindcss:watch のような行があるのでしょう。ただ、この行があるのに tailwindcss:watch task が用意されていない状況になっているのは謎です。手動で追記されたでしょうか?

通常であれば、rails new の際に --css tailwind オプションを付けるか、手動で tailwindcss-rails gem を bundle add した後 bin/rails tailwindcss:install するとセットアップが走ります(参考: https://github.com/rails/tailwindcss-rails/tree/v2.0.30#installation)。

状況的に tailwindcss-rails gem がインストールされていなさそうなので、Gemfile に無ければ手動インストールの手順を試してみてください。

1

この質問に回答するには、ログインする必要があります。

求めていた回答ではありませんか? のタグが付いた他の質問を参照する。