ruby-on-rails rails7 RAILS_ENV=production rails assets:pre编译错误Command“build”not found

jslywgbw  于 2023-08-08  发布在  Ruby
关注(0)|答案(2)|浏览(174)

非常奇怪的错误,资产预编译在开发模式下工作正常,但当我在生产模式下工作时,我得到错误:

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(我使用导入Map)。

hgncfbus

hgncfbus1#

嗯..我想出了如何做一个猴子补丁(叹气..)。
将此添加到package.json

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

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

neekobn8

neekobn82#

谢谢IvRRimUm我一直在寻找这个修复年龄。确保导入Map,如果您使用的是rails7,也要确保其设置正确。我发现这些指南很有用:
https://www.learnenough.com/blog/migrating-away-from-rails-webpackerhttps://eagerworks.com/blog/import-maps-in-rails-7的数据库

相关问题