The issue on my end was due to an unstable internet connection during npm install. As a result, some packages might not have installed correctly. To fix it, I deleted the node_modules folder and ran npm install again once the connection was stable. After that, npm run dev worked fine.