error: E_IOC_LOOKUP_FAILED while importing a model inside ace command #3408
Answered
by
W2AlharbiMe
W2AlharbiMe
asked this question in
Help
-
Hello, so i'm trying to create a series of ace commands and when i import the user model in a command in the run method like so import { BaseCommand } from '@adonisjs/core/build/standalone'
export default class UserNewMember extends BaseCommand {
/**
* Command name is used to run the command
*/
public static commandName = 'user:new'
/**
* Command description is displayed in the "help" output
*/
public static description = 'create a new user'
public static settings = {
/**
* Set the following value to true, if you want to load the application
* before running the command
*/
loadApp: true,
/**
* Set the following value to true, if you want this command to keep running until
* you manually decide to exit the process
*/
stayAlive: false,
}
public async run() {
const {default: User} = await import('App/Models/User');
const user = await User.find(1);
console.log(user);
}
} then run $ node ace generate:manifest finally i do this
User Model import { DateTime, } from 'luxon'
import { BaseModel, column } from '@ioc:Adonis/Lucid/Orm'
export default class User extends BaseModel {
@column({ isPrimary: true })
public id: number;
@column({})
public email: string;
@column({ serializeAs: null })
public password: string;
@column({})
public role: string;
@column.dateTime({ autoCreate: true })
public createdAt: DateTime;
@column.dateTime({ autoCreate: true, autoUpdate: true })
public updatedAt: DateTime;
} |
Beta Was this translation helpful? Give feedback.
Answered by
W2AlharbiMe
Dec 15, 2021
Replies: 1 comment 1 reply
-
Hello, and i don't know yet what happened but i fixed it when i run the $ node ace generate:manifest |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
W2AlharbiMe
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
quick updates about this
so i have been debugging this issue for 2 days
and i don't know yet what happened but i fixed it when i run the
following command right after i got the error: