React-rails安装错误找不到Webpacker配置文件

时间:2018-05-01 07:18:39

标签: ruby-on-rails ruby ruby-on-rails-4

将rails 3升级到rails 4.2.4之后,我想在我的project.i中使用react-rails gem。遵循官方的react-rails文档。

rake webpacker:install收到此错误。

Webpacker configuration file not found /home/projects/config/webpacker.yml. Please run rails webpacker:install Error: No such file or directory @ rb_sysopen - /home/projects/config/webpacker.yml
/home/.rvm/gems/ruby-2.3.4/gems/webpacker-3.5.2/lib/webpacker/configuration.rb:73:in `rescue in load'
/home/.rvm/gems/ruby-2.3.4/gems/webpacker-3.5.2/lib/webpacker/configuration.rb:70:in `load'
/home/.rvm/gems/ruby-2.3.4/gems/webpacker-3.5.2/lib/webpacker/configuration.rb:66:in `data'
/home/.rvm/gems/ruby-2.3.4/gems/webpacker-3.5.2/lib/webpacker/configuration.rb:62:in `fetch'
/home/.rvm/gems/ruby-2.3.4/gems/webpacker-3.5.2/lib/webpacker/configuration.rb:17:in `compile?'
/home/.rvm/gems/ruby-2.3.4/gems/webpacker-3.5.2/lib/webpacker/manifest.rb:32:in `compiling?'
/home/.rvm/gems/ruby-2.3.4/gems/webpacker-3.5.2/lib/webpacker/manifest.rb:22:in `lookup'
/home/.rvm/gems/ruby-2.3.4/gems/react-rails-2.4.4/lib/react/server_rendering/webpacker_manifest_container.rb:42:in `find_asset'
/home/.rvm/gems/ruby-2.3.4/gems/react-rails-2.4.4/lib/react/server_rendering/bundle_renderer.rb:27:in `block in initialize'
/home/.rvm/gems/ruby-2.3.4/gems/react-rails-2.4.4/lib/react/server_rendering/bundle_renderer.rb:26:in `each'
/home/.rvm/gems/ruby-2.3.4/gems/react-rails-2.4.4/lib/react/server_rendering/bundle_renderer.rb:26:in `initialize'
/home/.rvm/gems/ruby-2.3.4/gems/react-rails-2.4.4/lib/react/server_rendering.rb:17:in `new'
/home/.rvm/gems/ruby-2.3.4/gems/react-rails-2.4.4/lib/react/server_rendering.rb:17:in `block in reset_pool'
/home/.rvm/gems/ruby-2.3.4/gems/connection_pool-0.9.3/lib/timed_queue.rb:6:in `block in initialize'
/home/.rvm/gems/ruby-2.3.4/gems/connection_pool-0.9.3/lib/timed_queue.rb:6:in `initialize'
/home/.rvm/gems/ruby-2.3.4/gems/connection_pool-0.9.3/lib/timed_queue.rb:6:in `new'
/home/.rvm/gems/ruby-2.3.4/gems/connection_pool-0.9.3/lib/timed_queue.rb:6:in `initialize'
/home/.rvm/gems/ruby-2.3.4/gems/connection_pool-0.9.3/lib/connection_pool.rb:42:in `new'
/home/.rvm/gems/ruby-2.3.4/gems/connection_pool-0.9.3/lib/connection_pool.rb:42:in `initialize'
/home/.rvm/gems/ruby-2.3.4/gems/react-rails-2.4.4/lib/react/server_rendering.rb:17:in `new'
/home/.rvm/gems/ruby-2.3.4/gems/react-rails-2.4.4/lib/react/server_rendering.rb:17:in `reset_pool'
/home/.rvm/gems/ruby-2.3.4/gems/react-rails-2.4.4/lib/react/rails/railtie.rb:104:in `block in <class:Railtie>'
/home/.rvm/gems/ruby-2.3.4/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
/home/.rvm/gems/ruby-2.3.4/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
/home/.rvm/gems/ruby-2.3.4/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:44:in `each'
/home/.rvm/gems/ruby-2.3.4/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
/home/.rvm/gems/ruby-2.3.4/gems/railties-4.2.4/lib/rails/application/finisher.rb:62:in `block in <module:Finisher>'
/home/.rvm/gems/ruby-2.3.4/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `instance_exec'
/home/.rvm/gems/ruby-2.3.4/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `run'
/home/.rvm/gems/ruby-2.3.4/gems/railties-4.2.4/lib/rails/initializable.rb:55:in `block in run_initializers'
/home/.rvm/gems/ruby-2.3.4/gems/railties-4.2.4/lib/rails/initializable.rb:54:in `run_initializers'
/home/.rvm/gems/ruby-2.3.4/gems/railties-4.2.4/lib/rails/application.rb:352:in `initialize!'
/home/.rvm/gems/ruby-2.3.4/gems/railties-4.2.4/lib/rails/railtie.rb:194:in `public_send'
/home/.rvm/gems/ruby-2.3.4/gems/railties-4.2.4/lib/rails/railtie.rb:194:in `method_missing'
/home/projects/config/environment.rb:17:in `<top (required)>'
/home/.rvm/gems/ruby-2.3.4/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require'
/home/.rvm/gems/ruby-2.3.4/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `block in require'
/home/.rvm/gems/ruby-2.3.4/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:240:in `load_dependency'
/home/.rvm/gems/ruby-2.3.4/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require'
/home/.rvm/gems/ruby-2.3.4/gems/railties-4.2.4/lib/rails/application.rb:328:in `require_environment!'
/home/.rvm/gems/ruby-2.3.4/gems/railties-4.2.4/lib/rails/application.rb:457:in `block in run_tasks_blocks'
/home/.rvm/gems/ruby-2.3.4/gems/rake-12.3.1/exe/rake:27:in `<top (required)>'

请帮助我,我使用rails 4.2.4创建了新的演示应用程序,它运行正常,但不是我现有的应用程序。

3 个答案:

答案 0 :(得分:5)

将此文件放入文件夹/ Users / YourAPP / config https://github.com/rails/webpacker/blob/master/lib/install/config/webpacker.yml

答案 1 :(得分:2)

这是3个步骤:

  • 第1步:在config文件夹中创建一个webpacker.yml,这样路径将是           config / webpacker.yml
  • 第2步:将以下内容粘贴到webpacker.yml文件中。
    default: &default
      source_path: app/javascript
      source_entry_path: packs
      public_root_path: public
      public_output_path: packs
      cache_path: tmp/cache/webpacker
      check_yarn_integrity: false
      webpack_compile_output: false

      resolved_paths: []
      cache_manifest: false
      extract_css: false

      static_assets_extensions:
        - .jpg
        - .jpeg
        - .png
        - .gif
        - .tiff
        - .ico
        - .svg
        - .eot
        - .otf
        - .ttf
        - .woff
        - .woff2

      extensions:
        - .mjs
        - .js
        - .sass
        - .scss
        - .css
        - .module.sass
        - .module.scss
        - .module.css
        - .png
        - .svg
        - .gif
        - .jpeg
        - .jpg

    development:
      <<: *default
      compile: true

      check_yarn_integrity: true

      dev_server:
        https: false
        host: localhost
        port: 3035
        public: localhost:3035
        hmr: false
        inline: true
        overlay: true
        compress: true
        disable_host_check: true
        use_local_ip: false
        quiet: false
        pretty: false
        headers:
          'Access-Control-Allow-Origin': '*'
        watch_options:
          ignored: '**/node_modules/**'


    test:
      <<: *default
      compile: true

      # Compile test packs to a separate directory
      public_output_path: packs-test

    production:
      <<: *default

      # Production depends on precompilation of packs prior to booting for performance.
      compile: false

      # Extract and emit a css file
      extract_css: true

      # Cache manifest.json for perfo`enter code here`rmance
      cache_manifest: true
  • 第3步:重新启动服务器

答案 2 :(得分:1)

如果您没有这些文件,则可能是您尚未安装Yarn https://yarnpkg.com/lang/fr/docs/install/#mac-stable