DEV Community

sium_hossain
sium_hossain

Posted on

2

Cannot find module 'lib/axios'- nuxt 2.15.8 + vite integration error

Vite is a modern frontend build tool that provides an extremely fast development environment and bundles your code for production. It will change your development experience with super fast hot reloading πŸš….

But there is an issue with nuxt 2.15.8 in integration. You will get an error called - Cannot find module 'lib/axios'

So fix that, let's start from begging I mean from installation part-
To install vite with simple command

Official site link

npm i -D nuxt-vite
Enter fullscreen mode Exit fullscreen mode

Add to buildModules in nuxt.config.js

  buildModules: [
    'nuxt-vite'
  ],
Enter fullscreen mode Exit fullscreen mode

And now you will get this error Cannot find module 'lib/axios'. This problem comes from vite version. Let's downgrade, then our error will be gone.

In package.json file downgrade vite version "nuxt-vite: 0.3.5" to "nuxt-vite": "^0.2.4"

Then again install all dependencies by

npm install
Enter fullscreen mode Exit fullscreen mode

Now you can run npm run dev and enjoy vite blessing fast speed.

If you are in 1st place I mean you are going to install vite you can install specific version by

npm install nuxt-vite@0.2.4
Enter fullscreen mode Exit fullscreen mode

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (2)

Collapse
 
kissu profile image
Konstantin BIFERT β€’

Damn, never knew you could use Nuxt2 with Vite!
Meanwhile, it looks like this module is actually deprecated: github.com/nuxt/vite

Not sure that it's the best to use such package so. πŸ˜…

Collapse
 
siumhossain profile image
sium_hossain β€’

This package is actually deprecated πŸ˜‚

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs