Model/user not found - Production issue

#1

So I foolishly went against the naming convention used in Adonis for Models. All of my models in app/Models/ are lowercase. This wasn’t an issue in local dev, but now that I pushed to pr, I’m getting this error:

Error: Cannot find module '/var/app/current/app/Models/User'
Error: Cannot find module '/var/app/current/app/Models/User'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
    at Function.Module._load (internal/modules/cjs/loader.js:508:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at requireStack (/var/app/current/node_modules/require-stack/src/index.js:44:12)
    at Ioc._resolveAutoloadedPath (/var/app/current/node_modules/@adonisjs/fold/src/Ioc/index.js:265:20)
    at Ioc.make (/var/app/current/node_modules/@adonisjs/fold/src/Ioc/index.js:815:40)
    at LucidSerializer.setConfig (/var/app/current/node_modules/@adonisjs/auth/src/Serializers/Lucid.js:122:23)
    at Auth.authenticator (/var/app/current/node_modules/@adonisjs/auth/src/Auth/index.js:113:24)
    at new Auth (/var/app/current/node_modules/@adonisjs/auth/src/Auth/index.js:68:39)
    at Context.<anonymous> (/var/app/current/node_modules/@adonisjs/auth/providers/AuthProvider.js:151:14)
    at Context.wrappedCallback [as auth] (/var/app/current/node_modules/macroable/index.js:132:61)
    at Server._handleException (/var/app/current/node_modules/@adonisjs/framework/src/Server/index.js:253:63)
    at _executeServerMiddleware.then.then.catch (/var/app/current/node_modules/@adonisjs/framework/src/Server/index.js:441:14)

Rather than changing all the model naming convention, is there an easier way to deal with this?

0 Likes

#2

Hey @twigs67! :wave:

The main issue here is that you were using an OS that is not case sensitive to develop but your server is.

There’s two options there:

  1. You correct the configuration and put everything in lowercase
  2. You correct the file name and follow your configuration
1 Like

#3

I thought I checked everywhere… but not the config files.

Thanks @romain.lanz

1 Like