ruby-on-rails - 编译失败 : remote: ModuleNotFoundError: Module not found: Error When pushing to Heroku

标签 ruby-on-rails twitter-bootstrap heroku

我正在尝试将 RoR 网络应用程序推送到 Heroku,但出现以下构建错误:

remote:        Compilation failed:
remote:        ModuleNotFoundError: Module not found: Error: Can't resolve '../stylesheets/application' in '/tmp/build_7e435f25/app/javascript/packs'
remote:            at /tmp/build_7e435f25/node_modules/webpack/lib/Compilation.js:925:10
remote:            at /tmp/build_7e435f25/node_modules/webpack/lib/NormalModuleFactory.js:401:22
remote:            at /tmp/build_7e435f25/node_modules/webpack/lib/NormalModuleFactory.js:130:21
remote:            at /tmp/build_7e435f25/node_modules/webpack/lib/NormalModuleFactory.js:224:22
remote:            at /tmp/build_7e435f25/node_modules/neo-async/async.js:2830:7
remote:            at /tmp/build_7e435f25/node_modules/neo-async/async.js:6877:13
remote:            at /tmp/build_7e435f25/node_modules/webpack/lib/NormalModuleFactory.js:214:25
remote:            at /tmp/build_7e435f25/node_modules/enhanced-resolve/lib/Resolver.js:213:14
remote:            at /tmp/build_7e435f25/node_modules/enhanced-resolve/lib/Resolver.js:285:5
remote:            at eval (eval at create (/tmp/build_7e435f25/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
remote:            at /tmp/build_7e435f25/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:44:7
remote:            at /tmp/build_7e435f25/node_modules/enhanced-resolve/lib/Resolver.js:285:5
remote:            at eval (eval at create (/tmp/build_7e435f25/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
remote:            at /tmp/build_7e435f25/node_modules/enhanced-resolve/lib/Resolver.js:285:5
remote:            at eval (eval at create (/tmp/build_7e435f25/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:27:1)
remote:            at /tmp/build_7e435f25/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:67:43
remote:            at /tmp/build_7e435f25/node_modules/enhanced-resolve/lib/Resolver.js:285:5
remote:            at eval (eval at create (/tmp/build_7e435f25/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:16:1)
remote:            at /tmp/build_7e435f25/node_modules/enhanced-resolve/lib/RootPlugin.js:37:38
remote:            at _next42 (eval at create (/tmp/build_7e435f25/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:8:1)
remote:            at eval (eval at create (/tmp/build_7e435f25/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:31:1)
remote:            at /tmp/build_7e435f25/node_modules/enhanced-resolve/lib/Resolver.js:285:5
remote:            at eval (eval at create (/tmp/build_7e435f25/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:27:1)
remote:            at /tmp/build_7e435f25/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:67:43
remote:            at /tmp/build_7e435f25/node_modules/enhanced-resolve/lib/Resolver.js:285:5
remote:            at eval (eval at create (/tmp/build_7e435f25/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:16:1)
remote:            at /tmp/build_7e435f25/node_modules/enhanced-resolve/lib/Resolver.js:285:5
remote:            at eval (eval at create (/tmp/build_7e435f25/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
remote:            at /tmp/build_7e435f25/node_modules/enhanced-resolve/lib/DirectoryExistsPlugin.js:27:15
remote:            at /tmp/build_7e435f25/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:85:15
remote:        resolve '../stylesheets/application' in '/tmp/build_7e435f25/app/javascript/packs'
remote:          using description file: /tmp/build_7e435f25/package.json (relative path: ./app/javascript/packs)
remote:            Field 'browser' doesn't contain a valid alias configuration
remote:            using description file: /tmp/build_7e435f25/package.json (relative path: ./app/javascript/stylesheets/application)
remote:              no extension
remote:                Field 'browser' doesn't contain a valid alias configuration
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application doesn't exist
remote:              .mjs
remote:                Field 'browser' doesn't contain a valid alias configuration
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application.mjs doesn't exist
remote:              .js
remote:                Field 'browser' doesn't contain a valid alias configuration
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application.js doesn't exist
remote:              .sass
remote:                Field 'browser' doesn't contain a valid alias configuration
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application.sass doesn't exist
remote:              .scss
remote:                Field 'browser' doesn't contain a valid alias configuration
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application.scss doesn't exist
remote:              .css
remote:                Field 'browser' doesn't contain a valid alias configuration
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application.css doesn't exist
remote:              .module.sass
remote:                Field 'browser' doesn't contain a valid alias configuration
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application.module.sass doesn't exist
remote:              .module.scss
remote:                Field 'browser' doesn't contain a valid alias configuration
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application.module.scss doesn't exist
remote:              .module.css
remote:                Field 'browser' doesn't contain a valid alias configuration
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application.module.css doesn't exist
remote:              .png
remote:                Field 'browser' doesn't contain a valid alias configuration
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application.png doesn't exist
remote:              .svg
remote:                Field 'browser' doesn't contain a valid alias configuration
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application.svg doesn't exist
remote:              .gif
remote:                Field 'browser' doesn't contain a valid alias configuration
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application.gif doesn't exist
remote:              .jpeg
remote:                Field 'browser' doesn't contain a valid alias configuration
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application.jpeg doesn't exist
remote:              .jpg
remote:                Field 'browser' doesn't contain a valid alias configuration
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application.jpg doesn't exist
remote:              as directory
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application doesn't exist
remote:        
remote: 
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed
remote:  !
remote:  ! ## Warning - The same version of this code has already been built: 6cb1ee551129b46d6adf70c5e8e9788d0c8605f5
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version 6cb1ee551129b46d6adf70c5e8e9788d0c8605f5
remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote:  !
remote:  ! If you are developing on a branch and deploying via git you must run:
remote:  !
remote:  !     git push heroku <branchname>:main
remote:  !
remote:  ! This article goes into details on the behavior:
remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
remote: 
remote: Verifying deploy...
remote: 
remote: !   Push rejected to bee-arquitetura.
remote: 

我已经尝试查看 Bootstrap Sass 文档 [Bootstrap Sass Webpack 文档][1]

我最初有一个 Sass 错误,我能够解决这个错误,但我无法弄清楚是什么导致了这个错误。

最佳答案

尝试将路径“app/javascript/packs/application.js”中的“application.js”编辑为:

import Rails from "@rails/ujs"
import Turbolinks from "turbolinks"
import * as ActiveStorage from "@rails/activestorage"
import "channels"

Rails.start()
Turbolinks.start()
ActiveStorage.start()

import 'bootstrap/dist/js/bootstrap'
import 'bootstrap/dist/css/bootstrap'
require("stylesheets/application.scss")

关于ruby-on-rails - 编译失败 : remote: ModuleNotFoundError: Module not found: Error When pushing to Heroku,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69622539/

相关文章:

javascript - 如何获取 id 并根据 ror 中的该 id 显示下一个字段?

javascript - Heroku 路由错误 rails css/javascript 未加载

html - 在使用 Bootstrap 粘性 header 时遇到问题

node.js - 未找到 Heroku 应用程序

ios - 将 Parse Server iOS swift 应用程序连接到 Heroku

ruby-on-rails - 在fedora 20上安装TheRubyRacer gem时出错

html - 如何创建包含图像和文本的按钮

html - 如何让边框覆盖整个div

css - 反转 Twitter Bootstrip 网格中的列

ruby-on-rails - Ruby On Rails 回调在 Heroku 上不起作用,但在本地工作