like-gold
like-gold11mo ago

Missing "./dist/inferencers" specifier in "@refinedev/inferencer" package

I get the following error when running my dev server: Missing "./dist/inferencers" specifier in "@refinedev/inferencer" package I have ensured that I ran npm i @refinedev/inferencer again. I have ensured that "./dist/inferencers" exists and "./dist/inferencers/mui" as well. I have lastly also ensured that the following is set in both our tsconfig and vite config: "moduleResolution": "node", I am ensure how to fix this, there is a mismatch in the API's params between the edit ,the create and the show. I am unsure if this would cause this as I couldnt find much on this.
12 Replies
kapa.ai
kapa.ai11mo ago
Hi @haib. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Hmm, I don't know enough to give you a confident answer yet. However, there was a similar issue reported on the refine GitHub repository where TypeScript 5 couldn't find the type definition of @refinedev/inferencer. The temporary solution suggested was to set "moduleResolution": "node" in the tsconfig.json file, which you've already done. Here's the link to the issue for more context: GitHub Issue (https://github.com/refinedev/refine/issues/5528) Also, you might want to check the official documentation for @refinedev/inferencer for more information: Inferencer Documentation (https://refine.dev/docs/packages/inferencer) If the issue persists, I would recommend opening a new issue on the refine GitHub repository detailing your problem. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai11mo ago
<@525050092005359626> kapa.ai is still learning and improving, please let us know how it did by reacting below
like-gold
like-goldOP11mo ago
@kapa.ai is there a way to force the inferencer to use specific fields to generate the code?
kapa.ai
kapa.ai11mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- Based on the information provided in the extracts, the Inferencer in Refine tries to infer the data structure of the given resource and generates code based on that. However, there's no explicit mention of forcing the Inferencer to use specific fields to generate the code. The Inferencer sends API requests when mounted and then generates a code for that resource's data schema. You can see the preview and the generated code when you open the route you've added the Inferencer component. If the inferred fields are not as expected, you can modify the generated code as per your needs. Here's the link to the inferencer docs for more info about how it works and how it infers the fields: Inferencer Documentation (https://refine.dev/docs/packages/documentation/inferencer) If you need more control over the fields, you might want to manually define them instead of relying on the Inferencer. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai11mo ago
<@525050092005359626> kapa.ai is still learning and improving, please let us know how it did by reacting below
like-gold
like-goldOP11mo ago
@aliemir You resolved the previous PR, is there something I could be missing? It would be nice to have generated code to use as a basis but I'm leaning towards writing my own Create classes in some instances where not all the params are available yet due to API changes. Am I correct to believe it infers based on a GET request of the resource?
rival-black
rival-black11mo ago
Hey @haib sorry couldn't follow the question here. Did the first issue resolved about the inferencer imports?
like-gold
like-goldOP11mo ago
No, that is still the current issue When using the MuiInferencer on a specific /create I get the Missing "./dist/inferencers" specifier in "@refinedev/inferencer" package which seemed to be addressed in the PR. I have this issue currently, I figured it was because our params on the /create are very minimal while the /show and /edit have many more params. I thought this mismatch in params in the same resource may have lead to this. I am not sure if this is true though.
rival-black
rival-black11mo ago
Using fieldTransformer prop you can ignore the fields you don't want to be included in the generated code/preview. Check out the related section in the docs https://refine.dev/docs/packages/inferencer/#modifying-the-inferred-fields About the Missing specifier error, can you show how you import the component? It would be great to have a repro for us to investigate
like-gold
like-goldOP11mo ago
Not much special:
import {MuiInferencer} from "@refinedev/inferencer/dist/inferencers";
...

return(
...
resources={[...
{
name: "invoices",
list: "/invoices",
create: "/invoices/create",
show: "/invoices/show/:id",
edit: "/invoices/edit/:id",
meta: {
icon: <EuroIcon />
}

},
...
<Route path="invoices" element={
<CanAccess fallback={<NoAccess />}>
<Outlet />
</CanAccess>
}>
<Route index element={<InvoiceList />} />
<Route
path="edit/:id"
element={<InvoiceEdit />}
/>
<Route
path="show/:id"
element={<InvoiceShow />}
/>
<Route
path="create"
element={<MuiInferencer />}
/>
</Route>
...)
import {MuiInferencer} from "@refinedev/inferencer/dist/inferencers";
...

return(
...
resources={[...
{
name: "invoices",
list: "/invoices",
create: "/invoices/create",
show: "/invoices/show/:id",
edit: "/invoices/edit/:id",
meta: {
icon: <EuroIcon />
}

},
...
<Route path="invoices" element={
<CanAccess fallback={<NoAccess />}>
<Outlet />
</CanAccess>
}>
<Route index element={<InvoiceList />} />
<Route
path="edit/:id"
element={<InvoiceEdit />}
/>
<Route
path="show/:id"
element={<InvoiceShow />}
/>
<Route
path="create"
element={<MuiInferencer />}
/>
</Route>
...)
rival-black
rival-black11mo ago
MuiInferencer should be imported from @refinedev/inferencer/mui, I guess this is the issue here. Check out the docs here https://refine.dev/docs/ui-integrations/material-ui/components/inferencer/#usage
like-gold
like-goldOP11mo ago
Thank you for the time, I should have double checked that as auto-imports mess up sometimes