远程:!预编译资产失败。在heroku上(Rails 6和语义UI)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了远程:!预编译资产失败。在heroku上(Rails 6和语义UI)相关的知识,希望对你有一定的参考价值。

我正在尝试将Rails 6应用程序上的ruby部署到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但仍然出现相同的错误。

答案

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

发生这种情况是由于SemanticUI配置错误。我的app/javascript/packs/application.js有这个:

require("semantic-ui")

而不是:

//= require("semantic-ui")

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

以上是关于远程:!预编译资产失败。在heroku上(Rails 6和语义UI)的主要内容,如果未能解决你的问题,请参考以下文章

Heroku 部署错误;预编译资产失败(注意 devise.rb 中的行)

Heroku 上的“application.css 未预编译”错误,CDN 上有远程资产

Rails 4 Heroku 资产:预编译失败

推送到 heroku 时出现“预编译资产失败”错误

预编译资产失败的 Rails

Rake 资产:Heroku 错误上的预编译