W
Wasp2w ago
wbjb

Vite error

@kapa.ai I'm getting this error [plugin:vite:import-analysis] Failed to resolve import "@wasp/queries" from "../../../src/pages/Alerts.jsx". Does the file exist? /home/brad/route01/app/src/pages/Alerts.jsx:3:25 18 | import React, { useState } from "react"; 19 | import { Link } from "react-router-dom"; 20 | import { useQuery } from "@wasp/queries"; | ^ 21 | import { useAction } from "@wasp/actions"; 22 | import { getAlerts } from "@wasp/queries/getAlerts";
4 Replies
kapa.ai
kapa.ai2w ago
Hi @wbjb. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- It looks like you're encountering a Vite import resolution error in your Wasp application. This is a common issue that happens when the import paths aren't correctly formatted or when there's a mismatch between the Wasp version you're using and the import syntax. Based on the error, there are a few potential issues: 1. You might be using incorrect import paths for Wasp operations. The correct import format depends on your Wasp version. 2. For Wasp version 0.12.x (the latest), the import should be:
import { useQuery } from 'wasp/client/operations';
import { getAlerts } from 'wasp/queries/getAlerts';
import { useQuery } from 'wasp/client/operations';
import { getAlerts } from 'wasp/queries/getAlerts';
3. For Wasp version 0.11.x, the import should be:
import { useQuery } from '@wasp/queries';
import getAlerts from '@wasp/queries/getAlerts';
import { useQuery } from '@wasp/queries';
import getAlerts from '@wasp/queries/getAlerts';
Notice the difference in the import paths between versions and also how getAlerts is imported (with or without curly braces). This is a known issue in Wasp, especially after the restructuring in version 0.12, where error messages related to import paths can be confusing as noted in this GitHub issue. If you've recently migrated from 0.11.x to 0.12.x, make sure you've updated all your imports according to the migration guide. Also, double-check that you've properly defined your query in the main.wasp file and implemented it in your queries file. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @wbjb, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
wbjb
wbjbOP2w ago
@kapa.ai im still getting this error Missing "./server/queries.js" specifier in "wasp" package
kapa.ai
kapa.ai2w ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- I see you're still having import issues with your Wasp application. The error "Missing './server/queries.js' specifier in 'wasp' package" suggests that you're using an import path that doesn't match your Wasp version's expected format. This is likely related to the significant changes in project structure and import paths between Wasp 0.11.x and 0.12.x. Based on the knowledge sources, here's what might be happening: 1. If you're using Wasp 0.12.x, the import paths have changed significantly. In 0.12.x, all external imports in your Wasp file must have paths starting with @src instead of @server or @client as mentioned in the migration guide. 2. For your JavaScript/TypeScript files, the import paths have also changed. For example, if you're trying to import queries, the correct format in 0.12.x would be:
import { useQuery } from 'wasp/client/operations';
import { useQuery } from 'wasp/client/operations';
3. If you recently migrated from 0.11.x to 0.12.x, you might have missed updating some import paths. The migration guide recommends using a script to automatically update these imports:
npx jscodeshift -t <https://raw.githubusercontent.com/wasp-lang/wasp-codemod/main/src/transforms/imports-from-0-11-to-0-12.ts> --extensions=js,ts,jsx,tsx src/
npx jscodeshift -t <https://raw.githubusercontent.com/wasp-lang/wasp-codemod/main/src/transforms/imports-from-0-11-to-0-12.ts> --extensions=js,ts,jsx,tsx src/
4. Some paths like @shared/... might not have been converted properly during migration, as mentioned in a Discord support thread. To fix this specific error: 1. Check if you're using the correct import path for your Wasp version 2. If you're on 0.12.x, make sure you're not using @server or @client in your imports 3. Consider running the migration script again if you missed some imports 4. Verify that your query is properly defined in your main.wasp file If you're still having issues, it might help to share your main.wasp file and the specific import statement that's causing the error. I hope this helps resolve your import issue! ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @wbjb, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
miho
miho2w ago
I'd advise going through the Wasp tutorial to understand Wasp better: https://wasp.sh/docs/tutorial/create
1. Creating a New Project | Wasp
You'll need to have the latest version of Wasp installed locally to follow this tutorial. If you haven't installed it yet, check out the QuickStart guide!

Did you find this page helpful?