node:internal/modules/cjs/loader:1148 throw err; ^ Error: Cannot find module…
- User
node:internal/modules/cjs/loader:1148 throw err; ^
Error: Cannot find module '../../controllers/leagueController' Require stack:
- C:\Node js programs\Football App\football-app-backend\routes\leaguesRoutes.js
- C:\Node js programs\Football App\football-app-backend\server.js at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15) at Module._load (node:internal/modules/cjs/loader:986:27) at Module.require (node:internal/modules/cjs/loader:1233:19) at require (node:internal/modules/helpers:179:18) at Object. (C:\Node js programs\Football App\football-app-backend\routes\leaguesRoutes.js:4:26) at Module._compile (node:internal/modules/cjs/loader:1358:14) at Module._extensions..js (node:internal/modules/cjs/loader:1416:10) at Module.load (node:internal/modules/cjs/loader:1208:32) at Module._load (node:internal/modules/cjs/loader:1024:12) at Module.require (node:internal/modules/cjs/loader:1233:19) { code: 'MODULE_NOT_FOUND', requireStack: [ 'C:\Node js programs\Football App\football-app-backend\routes\leaguesRoutes.js', 'C:\Node js programs\Football App\football-app-backend\server.js' ] }
Node.js v20.13.1
- Assistant
The error message you're seeing is indicating that the Node.js runtime is unable to find the module located at
'../../controllers/leagueController'from the file'C:\Node js programs\Football App\football-app-backend\routes\leaguesRoutes.js'.Here are some steps you can take to troubleshoot and resolve this issue:
-
Check File Path:
- Make sure the path
'../../controllers/leagueController'is correct relative to the file'C:\Node js programs\Football App\football-app-backend\routes\leaguesRoutes.js'.
- Make sure the path
-
- User
Build Error Failed to compile
Next.js (14.2.13) ./component/LeagueSelector.tsx:7:1 Module not found: Can't resolve 'axios' 5 | import { Button } from "@/components/ui/button"; 6 | import { useRouter } from 'next/router';
7 | import axios from 'axios'; | ^ 8 | 9 | interface League { 10 | id: string;
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module: ./component/FootballDashboard.tsx
- Assistant
The error message you're encountering suggests that your Next.js application is unable to find the
axiosmodule when trying to import it in yourLeagueSelector.tsxcomponent. This is typically because theaxiospackage is not installed in your project. Here are steps to resolve the issue:-
Install axios:
- Open your terminal and run the following command to install
axios:
or if you're using Yarn:npm install axiosyarn add axios
- Open your terminal and run the following command to install
-
Verify Installation:
- After running the command, check your file to ensure is listed in the dependencies section:
-
- User
Unhandled Runtime Error Error: NextRouter was not mounted. https://nextjs.org/docs/messages/next-router-not-mounted
Source component\LeagueSelector.tsx (16:27) @ useRouter
14 | export default function LeagueSelector() { 15 | const [leagues, setLeagues] = useState<League[]>([]);
16 | const router = useRouter(); | ^ 17 | 18 | useEffect(() => { 19 | const fetchLeagues = async () => { Call Stack Show collapsed frames
- Assistant