I did deployed adonis js API app to Heroku successfully. I can register and login fine but when tried accessing other routes like products
I get an error Error: Cannot find module '/app/app/models/Product'
. The api works fine locally. I can't seem to find the cause of the error. I initially thought it could be the issue with autoload on package.json.
Here is my order models
'use strict'
/** @type {typeof import('@adonisjs/lucid/src/Lucid/Model')} */
const Model = use('Model')
class Order extends Model {
static get table() {
return 'orders'
}
static get primaryKey() {
return 'id'
}
user() {
return this.belongsTo('App/Models/User')
}
histories () {
return this.hasMany('App/Models/History')
}
}
module.exports = Order
And this how I import on OrderController.
const Order = use('App/models/Order')
When I have NODE_ENV
as development
, I get the following error on the browser.
in controller your path is wrong
you need to import like this
you write models
instead of writing Models
const Product = use('App/Models/Product')