FG
๐Ÿ’ป Software๐ŸŒ Web & Full-Stack

Running on root directory "Failed to resolve entry for package"

Fresh3 days ago
Mar 14, 20260 views
Confidence Score62%
62%

Problem

Describe the bug When running on Linux, in the root directory, if you try to access vite_url:3000/path-of-working-dir, you will get the following error: [code block] Steps to reproduce: 1. `cd /` 2. `npm create vite@latest my-vue-app -- --template vue` 3. `cd my-vue-app` 4. `npm run dev` 5. Access `http://192.168.64.13:3000/my-vue-app` 6. See error If `my-vue-app` is on any other folder other than `/` (root directory) this error doesn't happen. This is running on a Ubuntu VM inside my M1 Pro Macbook. Reproduction Reproduction steps above System Info [code block] Used Package Manager npm Logs [code block] ``` Validations - [X] Follow our Code of Conduct - [X] Read the Contributing Guidelines. - [X] Read the docs. - [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate. - [X] Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/core instead. - [X] Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server. - [X] The provided reproduction is a minimal reproducible example of the bug.

Error Output

error

If `my-vue-app` is on any other folder other than `/` (root directory) this error doesn't happen.

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix โ€“ Awaiting Verification

Change Working Directory for Vite Development Server

Low Risk

When running a Vite application from the root directory '/', the server may not resolve paths correctly due to permission issues or path resolution conflicts. This often leads to the error 'Failed to resolve entry for package' because Vite expects the application to be in a user directory where it can access the necessary files without restrictions.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Create a New Directory

    Instead of running the Vite application from the root directory, create a new directory in your home folder or any other user directory.

    bash
    mkdir ~/my-vue-apps
  2. 2

    Move to the New Directory

    Change your working directory to the newly created directory where you will set up the Vite application.

    bash
    cd ~/my-vue-apps
  3. 3

    Create Vite Application

    Run the Vite command to create a new Vue application in the new directory.

    bash
    npm create vite@latest my-vue-app -- --template vue
  4. 4

    Start the Development Server

    Navigate into the newly created application directory and start the Vite development server.

    bash
    cd my-vue-app && npm run dev
  5. 5

    Access the Application

    Open your web browser and access the application using the provided URL, replacing '192.168.64.13' with your local IP address if necessary.

    text
    http://192.168.64.13:3000/my-vue-app

Validation

To confirm the fix worked, ensure that you can access the application without encountering the 'Failed to resolve entry for package' error. The application should load correctly in your web browser.

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

vitebuild-tooljavascriptp3-minor-bug