rails7 RAILS_ENV=production rails assets:precompile 错误命令 "build" 未找到

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

非常奇怪的错误,资产预编译在开发模式下工作正常,但是一旦我进入生产模式,我就得到错误:

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#

最奇怪的是,我什至没有在我的项目中使用 yarn(我使用 importmaps)。

嗯..我想出了如何做一个猴子补丁(叹息..)。

将此添加到 package.json:

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

这不能解决使用 yarn/npm 的 rails prod 预处理器的问题(我不需要它们)。