I am trying to load my custom js. but getting errors.
Error is following.
Failed to register controller: notification (controllers/notification_controller) Error: Unable to resolve specifier '@noty' imported from http://localhost:3000/assets/controllers/notification_contr...
│ ├── javascript
│ │ ├── application.js
│ │ ├── controllers
│ │ │ ├── application.js
│ │ │ ├── index.js
│ │ │ ├── notification_controller.js
│ │ └── lib
│ │ └── noty.js
notification_controller.js
import { Controller } from "@hotwired/stimulus"
import Noty from "@noty"
export default class extends Controller {
static targets = [ 'type', 'message' ]
....// some codes.
}
config/importmap.rb
# Pin npm packages by running ./bin/importmap
pin "application", preload: true
pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true
pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true
pin_all_from "app/javascript/controllers", under: "controllers"
## lib
pin "@noty", to: "app/javascript/lib/noty.js", preload: true
What did I do wrong? also some other questions I have is, where "stimulus.min.js" and "turbo.min.js" file exist?