编译失败:远程:ModuleNotFoundError:找不到模块:推送到 Heroku 时出错
Posted
技术标签:
【中文标题】编译失败:远程:ModuleNotFoundError:找不到模块:推送到 Heroku 时出错【英文标题】:Compilation failed: remote: ModuleNotFoundError: Module not found: Error When pushing to Heroku 【发布时间】:2021-12-05 21:22:37 【问题描述】:我正在尝试将 RoR Web 应用程序推送到 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 doc][1]
我最初遇到了一个 Sass 错误,我能够解决,但我无法弄清楚可能导致此错误的原因。
【问题讨论】:
您将必须提供有关正在编译的文件(您的 Javascript 中使用的模块)的更多详细信息,但这看起来像是与文件和模块命名有关的错误检查您的 js 文件的导入区分大小写和文件名和位置。文件扩展名也起作用。也许您需要的文件格式是您的 webpack 配置不期望的? 【参考方案1】:我认为您必须重命名“应用程序”文件(路径:app/assets/stylesheets)并添加一个扩展名,如“.css”
实际名称:“应用程序”
修改名称:“application.css”
(路径:应用程序/资产/样式表)
【讨论】:
以上是关于编译失败:远程:ModuleNotFoundError:找不到模块:推送到 Heroku 时出错的主要内容,如果未能解决你的问题,请参考以下文章
远程:!预编译资产失败。在heroku上(Rails 6和语义UI)
Jupyter Notebook - ModuleNotFoundError [重复]