Rails Heroku 部署:预编译资产失败。 SassC::语法错误

问题描述 投票:0回答:1

在部署到 heroku RoR 项目期间出现错误“预编译资产失败”。

我尝试使用“calc(100vh - 110px)”查找CSS代码,但在项目中没有找到任何内容。

可能是什么问题?谢谢你

remote: -----> Installing node-v20.9.0-linux-x64
remote: -----> Installing yarn-v1.22.19
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        yarn install v1.22.19
remote:        [1/4] Resolving packages...
remote:        [2/4] Fetching packages...
remote:        [3/4] Linking dependencies...
remote:        warning " > [email protected]" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
remote:        warning "webpack-dev-server > [email protected]" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
remote:        [4/4] Building fresh packages...
remote:        Done in 15.09s.
remote:        rake aborted!
remote:        SassC::SyntaxError: Error: "calc(100vh - 110px)" is not a number for `min'
remote:                on line 1:30534 of stdin, in function `min`
remote:                from line 1:30534 of stdin
remote:        >> x;flex:1;flex-direction:column;max-height:min(650px,calc(100vh - 110px));ove
remote:           ------------------------------------------^
remote:        stdin:1

我确实尝试运行rails asset:precompile:

    Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
    /Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/set.rb:648: warning: already initialized constant Set::InspectKey
    /Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/set-1.0.3/lib/set.rb:815: warning: previous definition of InspectKey was here
    /Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/pathname.rb:20: warning: already initialized constant Pathname::TO_PATH
    /Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/pathname-0.2.1/lib/pathname.rb:20: warning: previous definition of TO_PATH was here
    /Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/pathname.rb:22: warning: already initialized constant Pathname::SAME_PATHS
    /Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/pathname-0.2.1/lib/pathname.rb:22: warning: previous definition of SAME_PATHS was here
    /Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/pathname.rb:34: warning: already initialized constant Pathname::SEPARATOR_LIST
    /Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/pathname-0.2.1/lib/pathname.rb:34: warning: previous definition of SEPARATOR_LIST was here
    /Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/pathname.rb:35: warning: already initialized constant Pathname::SEPARATOR_PAT
    /Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/pathname-0.2.1/lib/pathname.rb:35: warning: previous definition of SEPARATOR_PAT was here
    /Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/pathname.rb:41: warning: already initialized constant Pathname::ABSOLUTE_PATH
    /Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/pathname-0.2.1/lib/pathname.rb:41: warning: previous definition of ABSOLUTE_PATH was here
    Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
    /Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/set.rb:648: warning: already initialized constant Set::InspectKey
    /Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/set-1.0.3/lib/set.rb:815: warning: previous definition of InspectKey was here
    Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
    /Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/set.rb:648: warning: already initialized constant Set::InspectKey
    /Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/set-1.0.3/lib/set.rb:815: warning: previous definition of InspectKey was here
    yarn install v1.22.15
    warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
    [1/4] 🔍  Resolving packages...
    success Already up-to-date.
    ✨  Done in 0.15s.
    Warning: you are using an unstable release of Node.js (v21.2.0). If you encounter issues with Node.js, consider switching to an Active LTS release. More info: https://docs.npmjs.com/try-the-latest-stable-version-of-node
    Everything's up-to-date. Nothing to do

我也尝试过:RAILS_ENV=生产轨道资产:预编译

olegmishyn@MacBook-Air-Oleg learnician % RAILS_ENV=production rails assets:precompile SECRET_KEY_BASE='07788fabf3594bf7c2d898acfd331bb39294bb613c2609e9d2966cd5593a3cb0131be5ce5165de67a10f24ade4bf45e5d74e80104beb79404f0f441b93e46eff'

Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
/Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/set.rb:648: warning: already initialized constant Set::InspectKey
/Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/set-1.0.3/lib/set.rb:815: warning: previous definition of InspectKey was here
/Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/pathname.rb:20: warning: already initialized constant Pathname::TO_PATH
/Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/pathname-0.2.1/lib/pathname.rb:20: warning: previous definition of TO_PATH was here
/Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/pathname.rb:22: warning: already initialized constant Pathname::SAME_PATHS
/Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/pathname-0.2.1/lib/pathname.rb:22: warning: previous definition of SAME_PATHS was here
/Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/pathname.rb:34: warning: already initialized constant Pathname::SEPARATOR_LIST
/Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/pathname-0.2.1/lib/pathname.rb:34: warning: previous definition of SEPARATOR_LIST was here
/Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/pathname.rb:35: warning: already initialized constant Pathname::SEPARATOR_PAT
/Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/pathname-0.2.1/lib/pathname.rb:35: warning: previous definition of SEPARATOR_PAT was here
/Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/pathname.rb:41: warning: already initialized constant Pathname::ABSOLUTE_PATH
/Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/pathname-0.2.1/lib/pathname.rb:41: warning: previous definition of ABSOLUTE_PATH was here
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
/Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/set.rb:648: warning: already initialized constant Set::InspectKey
/Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/set-1.0.3/lib/set.rb:815: warning: previous definition of InspectKey was here
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
/Users/olegmishyn/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/set.rb:648: warning: already initialized constant Set::InspectKey
/Users/olegmishyn/.rvm/gems/ruby-3.0.0/gems/set-1.0.3/lib/set.rb:815: warning: previous definition of InspectKey was here
yarn install v1.22.15
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] 🔍  Resolving packages...
success Already up-to-date.
✨  Done in 0.15s.
rails aborted!
SassC::SyntaxError: Error: "calc(100vh - 110px)" is not a number for `min'
        on line 1:30534 of stdin, in function `min`
        from line 1:30534 of stdin
>> x;flex:1;flex-direction:column;max-height:min(650px,calc(100vh - 110px));ove
   ------------------------------------------^

Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
ruby-on-rails heroku compilation assets
1个回答
0
投票

通过将 config.assets.css_compressor = nil 添加到 application.rb 和 production.rb 来修复它 + 将 node.js 版本更改为 "engines": { "node": "16.13.1" } 在 package.json

© www.soinside.com 2019 - 2024. All rights reserved.