【问题标题】:Remote: ! Precompiling assets failed. on heroku (Rails 6 and semantic-ui)偏僻的: !预编译资产失败。在 heroku 上(Rails 6 和语义 ui)
【发布时间】:2020-01-23 19:09:28
【问题描述】:

我正在尝试将我的 ruby​​ on rails 6 应用程序部署到 heroku,我得到:

...
remote:        I, [2020-01-23T18:51:26.163296 #1627]  INFO -- : Writing /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/public/assets/semantic-ui/brand-icons-42e369dc8c372973ba77a826b62d2c7a2070532313df832a23288ddb76974158.ttf
remote:        I, [2020-01-23T18:51:26.163727 #1627]  INFO -- : Writing /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/public/assets/semantic-ui/brand-icons-42e369dc8c372973ba77a826b62d2c7a2070532313df832a23288ddb76974158.ttf.gz
remote:        I, [2020-01-23T18:51:26.164090 #1627]  INFO -- : Writing /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/public/assets/semantic-ui/brand-icons-6519a15b08294be395ed914c40236ba604214cb1163b5311a9875f1df5eed86d.svg
remote:        I, [2020-01-23T18:51:26.164873 #1627]  INFO -- : Writing /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/public/assets/semantic-ui/brand-icons-6519a15b08294be395ed914c40236ba604214cb1163b5311a9875f1df5eed86d.svg.gz
remote:        Compiling...
remote:        Compilation failed:
remote:        ModuleNotFoundError: Module not found: Error: Can't resolve 'semantic-ui-sass' in '/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/app/javascript/packs'
remote:            at factory.create (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/webpack/lib/Compilation.js:925:10)
remote:            at factory (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/webpack/lib/NormalModuleFactory.js:401:22)
remote:            at resolver (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/webpack/lib/NormalModuleFactory.js:130:21)
remote:            at asyncLib.parallel (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/webpack/lib/NormalModuleFactory.js:224:22)
remote:            at /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/neo-async/async.js:2830:7
remote:            at /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/neo-async/async.js:6877:13
remote:            at normalResolver.resolve (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/webpack/lib/NormalModuleFactory.js:214:25)
remote:            at doResolve (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:213:14)
remote:            at hook.callAsync (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:285:5)
remote:            at _fn0 (eval at create (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
remote:            at resolver.doResolve (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/webpack/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:44:7)
remote:            at hook.callAsync (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:285:5)
remote:            at _fn0 (eval at create (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
remote:            at hook.callAsync (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:285:5)
remote:            at _fn0 (eval at create (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:27:1)
remote:            at resolver.doResolve (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/webpack/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:67:43)
remote:            at hook.callAsync (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:285:5)
remote:            at _fn41 (eval at create (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:28:1)
remote:            at resolver.doResolve (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/webpack/node_modules/enhanced-resolve/lib/ModuleKindPlugin.js:30:40)
remote:            at hook.callAsync (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:285:5)
remote:            at _fn0 (eval at create (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
remote:            at hook.callAsync (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:285:5)
remote:            at _fn1 (eval at create (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:16:1)
remote:            at args (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/webpack/node_modules/enhanced-resolve/lib/forEachBail.js:30:14)
remote:            at hook.callAsync (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:285:5)
remote:            at _fn0 (eval at create (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
remote:            at resolver.doResolve (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/webpack/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:44:7)
remote:            at hook.callAsync (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:285:5)
remote:            at _fn0 (eval at create (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
remote:            at hook.callAsync (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:285:5)
remote:            at _fn0 (eval at create (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:27:1)
remote:            at resolver.doResolve (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/webpack/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:67:43)
remote:            at hook.callAsync (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:285:5)
remote:            at _fn42 (eval at create (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:16:1)
remote:            at hook.callAsync (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:285:5)
remote:            at _fn0 (eval at create (/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:27:1)
remote:        resolve 'semantic-ui-sass' in '/tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/app/javascript/packs'
remote:          Parsed request is a module
remote:          using description file: /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/package.json (relative path: ./app/javascript/packs)
remote:            Field 'browser' doesn't contain a valid alias configuration
remote:            resolve as module
remote:              looking for modules in /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/app/javascript
remote:                using description file: /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/package.json (relative path: ./app/javascript)
remote:                  Field 'browser' doesn't contain a valid alias configuration
remote:                  using description file: /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/package.json (relative path: ./app/javascript/semantic-ui-sass)
remote:                    no extension
remote:                      Field 'browser' doesn't contain a valid alias configuration
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/app/javascript/semantic-ui-sass doesn't exist
remote:                    .mjs
remote:                      Field 'browser' doesn't contain a valid alias configuration
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/app/javascript/semantic-ui-sass.mjs doesn't exist
remote:                    .js
remote:                      Field 'browser' doesn't contain a valid alias configuration
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/app/javascript/semantic-ui-sass.js doesn't exist
remote:                    .sass
remote:                      Field 'browser' doesn't contain a valid alias configuration
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/app/javascript/semantic-ui-sass.sass doesn't exist
remote:                    .scss
remote:                      Field 'browser' doesn't contain a valid alias configuration
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/app/javascript/semantic-ui-sass.scss doesn't exist
remote:                    .css
remote:                      Field 'browser' doesn't contain a valid alias configuration
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/app/javascript/semantic-ui-sass.css doesn't exist
remote:                    .module.sass
remote:                      Field 'browser' doesn't contain a valid alias configuration
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/app/javascript/semantic-ui-sass.module.sass doesn't exist
remote:                    .module.scss
remote:                      Field 'browser' doesn't contain a valid alias configuration
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/app/javascript/semantic-ui-sass.module.scss doesn't exist
remote:                    .module.css
remote:                      Field 'browser' doesn't contain a valid alias configuration
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/app/javascript/semantic-ui-sass.module.css doesn't exist
remote:                    .png
remote:                      Field 'browser' doesn't contain a valid alias configuration
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/app/javascript/semantic-ui-sass.png doesn't exist
remote:                    .svg
remote:                      Field 'browser' doesn't contain a valid alias configuration
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/app/javascript/semantic-ui-sass.svg doesn't exist
remote:                    .gif
remote:                      Field 'browser' doesn't contain a valid alias configuration
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/app/javascript/semantic-ui-sass.gif doesn't exist
remote:                    .jpeg
remote:                      Field 'browser' doesn't contain a valid alias configuration
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/app/javascript/semantic-ui-sass.jpeg doesn't exist
remote:                    .jpg
remote:                      Field 'browser' doesn't contain a valid alias configuration
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/app/javascript/semantic-ui-sass.jpg doesn't exist
remote:                    as directory
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/app/javascript/semantic-ui-sass doesn't exist
remote:              /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/app/javascript/packs/node_modules doesn't exist or is not a directory
remote:              /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/app/javascript/node_modules doesn't exist or is not a directory
remote:              /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/app/node_modules doesn't exist or is not a directory
remote:              /tmp/node_modules doesn't exist or is not a directory
remote:              /node_modules doesn't exist or is not a directory
remote:              looking for modules in /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules
remote:                using description file: /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/package.json (relative path: ./node_modules)
remote:                  Field 'browser' doesn't contain a valid alias configuration
remote:                  using description file: /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/package.json (relative path: ./node_modules/semantic-ui-sass)
remote:                    no extension
remote:                      Field 'browser' doesn't contain a valid alias configuration
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/semantic-ui-sass doesn't exist
remote:                    .mjs
remote:                      Field 'browser' doesn't contain a valid alias configuration
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/semantic-ui-sass.mjs doesn't exist
remote:                    .js
remote:                      Field 'browser' doesn't contain a valid alias configuration
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/semantic-ui-sass.js doesn't exist
remote:                    .sass
remote:                      Field 'browser' doesn't contain a valid alias configuration
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/semantic-ui-sass.sass doesn't exist
remote:                    .scss
remote:                      Field 'browser' doesn't contain a valid alias configuration
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/semantic-ui-sass.scss doesn't exist
remote:                    .css
remote:                      Field 'browser' doesn't contain a valid alias configuration
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/semantic-ui-sass.css doesn't exist
remote:                    .module.sass
remote:                      Field 'browser' doesn't contain a valid alias configuration
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/semantic-ui-sass.module.sass doesn't exist
remote:                    .module.scss
remote:                      Field 'browser' doesn't contain a valid alias configuration
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/semantic-ui-sass.module.scss doesn't exist
remote:                    .module.css
remote:                      Field 'browser' doesn't contain a valid alias configuration
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/semantic-ui-sass.module.css doesn't exist
remote:                    .png
remote:                      Field 'browser' doesn't contain a valid alias configuration
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/semantic-ui-sass.png doesn't exist
remote:                    .svg
remote:                      Field 'browser' doesn't contain a valid alias configuration
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/semantic-ui-sass.svg doesn't exist
remote:                    .gif
remote:                      Field 'browser' doesn't contain a valid alias configuration
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/semantic-ui-sass.gif doesn't exist
remote:                    .jpeg
remote:                      Field 'browser' doesn't contain a valid alias configuration
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/semantic-ui-sass.jpeg doesn't exist
remote:                    .jpg
remote:                      Field 'browser' doesn't contain a valid alias configuration
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/semantic-ui-sass.jpg doesn't exist
remote:                    as directory
remote:                      /tmp/build_f6fcbd9561d1b9a0ac9f0eb2c4fc1207/node_modules/semantic-ui-sass doesn't exist
remote:        
remote: 
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed

当我这样做时,我已经尝试过this

# config/application.rb
config.assets.initialize_on_precompile = false

错误仍然存​​在。我做了this

NODE_ENV=production RAILS_ENV=production rails assets:precompile --trace

在本地一切正常,但如果我在本地打开样式不存在,并且如果我部署到 heroku,同样的错误仍然存​​在。 也试过this 但仍然得到同样的错误。

【问题讨论】:

  • 你解决过这个问题吗?我正在尝试将一个新的 rails 6 项目部署到 heroku 并且也遇到了这个问题

标签: ruby-on-rails heroku webpack semantic-ui ruby-on-rails-6


【解决方案1】:

我在将我的 Rails6 + Semantic UI 应用程序部署到 Heroku 时也遇到了这个问题——发布我的解决方案以防对未来的人有帮助:

这是由于 SemanticUI 配置错误造成的。我的app/javascript/packs/application.js 有这个:

require("semantic-ui")

代替:

//= require("semantic-ui")

修复此行后,我的应用能够正确构建和部署。

【讨论】:

    【解决方案2】:

    检查您的package.json

    我刚刚遇到同样的错误,发现我的 semantic-ui-sass 包在 devdependecies 部分,因此没有安装在生产环境中。

    $ yarn remove semantic-ui-sass
    
    $ yarn add semantic-ui-sass --prod
    

    【讨论】:

      猜你喜欢
      • 2021-11-12
      • 1970-01-01
      • 2022-01-26
      • 1970-01-01
      • 2014-06-27
      • 1970-01-01
      • 2021-01-07
      • 2023-04-04
      • 1970-01-01
      相关资源
      最近更新 更多