运行此命令RAILS_ENV=production bin/RAILS assets:precompile后出现此错误


yarn install v1.22.19
[1/4] 🔍  Resolving packages...
success Nothing to install.
success Saved lockfile.
✨  Done in 0.12s.
rails aborted!
Uglifier::Error: 
/Users/dev/.rvm/gems/ruby-2.7.5/gems/uglifier-4.2.0/lib/uglifier.rb:291:in `parse_result'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/uglifier-4.2.0/lib/uglifier.rb:221:in `run_uglifyjs'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/uglifier-4.2.0/lib/uglifier.rb:166:in `compile'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-3.7.2/lib/sprockets/compressing.rb:65:in `block in js_compressor='
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-3.7.2/lib/sprockets/legacy_proc_processor.rb:31:in `call'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:75:in `call_processor'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:56:in `reverse_each'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:56:in `call_processors'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-3.7.2/lib/sprockets/loader.rb:134:in `load_from_unloaded'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-3.7.2/lib/sprockets/loader.rb:60:in `block in load'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-3.7.2/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-3.7.2/lib/sprockets/loader.rb:44:in `load'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:47:in `load'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-3.7.2/lib/sprockets/base.rb:66:in `find_asset'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-3.7.2/lib/sprockets/base.rb:73:in `find_all_linked_assets'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:142:in `block in find'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:228:in `block in stat_tree'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:212:in `block in stat_directory'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:209:in `each'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:209:in `stat_directory'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:227:in `stat_tree'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:105:in `each'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:105:in `block in logical_paths'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:104:in `each'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:104:in `logical_paths'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:140:in `find'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:186:in `compile'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-rails-3.4.2/lib/sprockets/rails/task.rb:67:in `block (3 levels) in define'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-3.7.2/lib/rake/sprocketstask.rb:147:in `with_logger'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/sprockets-rails-3.4.2/lib/sprockets/rails/task.rb:66:in `block (2 levels) in define'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/railties-5.2.8.1/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/railties-5.2.8.1/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/railties-5.2.8.1/lib/rails/command.rb:48:in `invoke'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/railties-5.2.8.1/lib/rails/commands.rb:18:in `<main>'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/Users/dev/Documents/insta-clone/bin/rails:11:in `<top (required)>'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in `load'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in `call'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/spring-2.1.1/lib/spring/client/command.rb:7:in `call'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/spring-2.1.1/lib/spring/client.rb:30:in `run'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/spring-2.1.1/bin/spring:49:in `<top (required)>'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `load'
/Users/dev/.rvm/gems/ruby-2.7.5/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `<top (required)>'
/Users/dev/Documents/insta-clone/bin/spring:16:in `<top (required)>'
bin/rails:5:in `load'
bin/rails:5:in `<main>'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)

在config/environments/production.rb 中注释这一行

config.assets.js_compressor = :uglifier

它还将解决部署在Heroku 上时Assetpipeline的错误

相关内容

  • 没有找到相关文章

最新更新