Не удается разрешить развертывание Heroku @hotwired/stimulus-loading на Rails 7
Помогите .. Когда я развертывал Heroku в своем приложении rails, я получаю эту ошибку на терминале. Кстати, я использую Rails 7.0.1 на Ruby 3.0.3.
Compilation failed:
remote: [webpack-cli] ModuleNotFoundError: Module not found: Error: Can't resolve '@hotwired/stimulus-loading' in '/tmp/build_bc8927d3/app/javascript/controllers'
remote: at /tmp/build_bc8927d3/node_modules/webpack/lib/Compilation.js:2014:28
remote: at /tmp/build_bc8927d3/node_modules/webpack/lib/NormalModuleFactory.js:791:13
remote: at eval (eval at create (/tmp/build_bc8927d3/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:10:1)
remote: at /tmp/build_bc8927d3/node_modules/webpack/lib/NormalModuleFactory.js:265:22
remote: at eval (eval at create (/tmp/build_bc8927d3/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
remote: at /tmp/build_bc8927d3/node_modules/webpack/lib/NormalModuleFactory.js:427:22
remote: at /tmp/build_bc8927d3/node_modules/webpack/lib/NormalModuleFactory.js:111:11
remote: at /tmp/build_bc8927d3/node_modules/webpack/lib/NormalModuleFactory.js:663:25
remote: at /tmp/build_bc8927d3/node_modules/webpack/lib/NormalModuleFactory.js:848:8
remote: at /tmp/build_bc8927d3/node_modules/webpack/lib/NormalModuleFactory.js:968:5
remote: resolve '@hotwired/stimulus-loading' in '/tmp/build_bc8927d3/app/javascript/controllers'
remote: Parsed request is a module
remote: using description file: /tmp/build_bc8927d3/package.json (relative path: ./app/javascript/controllers)
remote: Field 'browser' doesn't contain a valid alias configuration
remote: resolve as module
remote: looking for modules in /tmp/build_bc8927d3/app/javascript
remote: single file module
remote: using description file: /tmp/build_bc8927d3/package.json (relative path: ./app/javascript/@hotwired/stimulus-loading)
remote: no extension
remote: Field 'browser' doesn't contain a valid alias configuration
remote: /tmp/build_bc8927d3/app/javascript/@hotwired/stimulus-loading doesn't exist
remote: .js
remote: Field 'browser' doesn't contain a valid alias configuration
remote: /tmp/build_bc8927d3/app/javascript/@hotwired/stimulus-loading.js doesn't exist
remote: .jsx
remote: Field 'browser' doesn't contain a valid alias configuration
remote: /tmp/build_bc8927d3/app/javascript/@hotwired/stimulus-loading.jsx doesn't exist
remote: .mjs
remote: Field 'browser' doesn't contain a valid alias configuration
remote: /tmp/build_bc8927d3/app/javascript/@hotwired/stimulus-loading.mjs doesn't exist
remote: .ts
remote: Field 'browser' doesn't contain a valid alias configuration
remote: /tmp/build_bc8927d3/app/javascript/@hotwired/stimulus-loading.ts doesn't exist
remote: .tsx
remote: Field 'browser' doesn't contain a valid alias configuration
remote: /tmp/build_bc8927d3/app/javascript/@hotwired/stimulus-loading.tsx doesn't exist
remote: .coffee
remote: Field 'browser' doesn't contain a valid alias configuration
remote: /tmp/build_bc8927d3/app/javascript/@hotwired/stimulus-loading.coffee doesn't exist
remote: /tmp/build_bc8927d3/app/javascript/@hotwired/stimulus-loading doesn't exist
remote: /tmp/build_bc8927d3/app/javascript/controllers/node_modules doesn't exist or is not a directory
remote: /tmp/build_bc8927d3/app/javascript/node_modules doesn't exist or is not a directory
remote: /tmp/build_bc8927d3/app/node_modules doesn't exist or is not a directory
remote: looking for modules in /tmp/build_bc8927d3/node_modules
remote: single file module
remote: using description file: /tmp/build_bc8927d3/package.json (relative path: ./node_modules/@hotwired/stimulus-loading)
remote: no extension
remote: Field 'browser' doesn't contain a valid alias configuration
remote: /tmp/build_bc8927d3/node_modules/@hotwired/stimulus-loading doesn't exist
remote: .js
remote: Field 'browser' doesn't contain a valid alias configuration
remote: /tmp/build_bc8927d3/node_modules/@hotwired/stimulus-loading.js doesn't exist
remote: .jsx
remote: Field 'browser' doesn't contain a valid alias configuration
remote: /tmp/build_bc8927d3/node_modules/@hotwired/stimulus-loading.jsx doesn't exist
remote: .mjs
remote: Field 'browser' doesn't contain a valid alias configuration
remote: /tmp/build_bc8927d3/node_modules/@hotwired/stimulus-loading.mjs doesn't exist
remote: .ts
remote: Field 'browser' doesn't contain a valid alias configuration
remote: /tmp/build_bc8927d3/node_modules/@hotwired/stimulus-loading.ts doesn't exist
remote: .tsx
remote: Field 'browser' doesn't contain a valid alias configuration
remote: /tmp/build_bc8927d3/node_modules/@hotwired/stimulus-loading.tsx doesn't exist
remote: .coffee
remote: Field 'browser' doesn't contain a valid alias configuration
remote: /tmp/build_bc8927d3/node_modules/@hotwired/stimulus-loading.coffee doesn't exist
remote: /tmp/build_bc8927d3/node_modules/@hotwired/stimulus-loading doesn't exist
remote: /tmp/node_modules doesn't exist or is not a directory
remote: /node_modules doesn't exist or is not a directory
У меня есть это в моем gemfile
gem "stimulus-rails"
а я уже пробовал
rails stimulus:install
В моем приложении/Javascipt/Controllers/application.js
import { Application } from "@hotwired/stimulus"
const application = Application.start()
// Configure Stimulus development experience
application.debug = false
window.Stimulus = application
export { application }
но все же я получаю ту же ошибку каждый раз, когда развертываю ее на героку, приложение отлично работает локально.
2 ответа
Насколько я могу судить,
@hotwired/stimulus-loading
package не был опубликован в NPM и предназначен для использования с importmaps в Rails. Если вместо этого вы используете веб-пакет, загляните в
@hotwired/stimulus-webpack-helpers
.
Проблема исправлена..
я пробовал комментировать
import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
из App/javascript/controllers/index.js, и это работает!
PS: это временное исправление, но оно не решит основной проблемы.