Search code examples
ruby-on-railsruby-on-rails-7rails7

rails7 RAILS_ENV=production rails assets:precompile error Command "build" not found


Extremly odd error, asset precompilation works fine in dev mode, but as soon as i do production mode, i get error:

root@53407ec15126:/app# RAILS_ENV=production rails assets:precompile
yarn install v1.22.18
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.04s.
yarn run v1.22.18
error Command "build" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
rails aborted!
jsbundling-rails: Command build failed, ensure yarn is installed and `yarn build` runs without errors

Tasks: TOP => assets:precompile => javascript:build
(See full trace by running task with --trace)
root@53407ec15126:/chinese-flashcards-app#

And the weirdest thing is, i dont even use yarn in my project(i use importmaps).


Solution

  • Well.. I figured out how to do a monkey patch(Sigh..).

    Add this to package.json:

      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "build": "echo 1",
        "build:css": "echo 1"
      },
    

    This does not resolve the issue of rails prod preprocessor using yarn/npm tho(i dont need them).