question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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:

Failed to resolve entry for package "/my-vue-app". The package may have incorrect main/module/exports specified in its package.json: Failed to resolve entry for package "/my-vue-app". The package may have incorrect main/module/exports specified in its package.json.

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

System:
    OS: Linux 5.4 Ubuntu 20.04.3 LTS (Focal Fossa)
    CPU: (4) arm64 unknown
    Memory: 1.27 GB / 7.75 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 16.13.2 - /usr/bin/node
    Yarn: 1.22.15 - /usr/bin/yarn
    npm: 8.1.2 - /usr/bin/npm
  Browsers:
    Chromium: 98.0.4758.80
  npmPackages:
    @vitejs/plugin-vue: ^2.2.0 => 2.2.0
    vite: ^2.8.0 => 2.8.0

Used Package Manager

npm

Logs

Failed to resolve entry for package "/my-vue-app". The package may have incorrect main/module/exports specified in its package.json: Failed to resolve entry for package "/my-vue-app". The package may have incorrect main/module/exports specified in its package.json.
    at packageEntryFailure (/my-vue-app/node_modules/vite/dist/node/chunks/dep-c9c9d3e5.js:29511:11)
    at resolvePackageEntry (/my-vue-app/node_modules/vite/dist/node/chunks/dep-c9c9d3e5.js:29507:9)
    at tryResolveFile (/my-vue-app/node_modules/vite/dist/node/chunks/dep-c9c9d3e5.js:29237:38)
    at tryFsResolve (/my-vue-app/node_modules/vite/dist/node/chunks/dep-c9c9d3e5.js:29219:16)
    at Context.resolveId (/my-vue-app/node_modules/vite/dist/node/chunks/dep-c9c9d3e5.js:29112:56)
    at Object.resolveId (/my-vue-app/node_modules/vite/dist/node/chunks/dep-c9c9d3e5.js:38242:55)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async ModuleGraph.resolveUrl (/my-vue-app/node_modules/vite/dist/node/chunks/dep-c9c9d3e5.js:53426:26)
    at async ModuleGraph.getModuleByUrl (/my-vue-app/node_modules/vite/dist/node/chunks/dep-c9c9d3e5.js:53311:23)
    at async doTransform (/my-vue-app/node_modules/vite/dist/node/chunks/dep-c9c9d3e5.js:52879:20


### Validations

- [X] Follow our [Code of Conduct](https://github.com/vitejs/vite/blob/main/CODE_OF_CONDUCT.md)
- [X] Read the [Contributing Guidelines](https://github.com/vitejs/vite/blob/main/CONTRIBUTING.md).
- [X] Read the [docs](https://vitejs.dev/guide).
- [X] Check that there isn't [already an issue](https://github.com/vitejs/vite/issues) 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](https://github.com/vitejs/vite/discussions) or join our [Discord Chat Server](https://chat.vitejs.dev/).
- [X] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:22 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
chris-sabcommented, Aug 17, 2022

Hello @poyoho Nice to meet you. Now I am having this issue:

[vite] Internal server error: Cannot set properties of undefined (setting 'isSelfAccepting')
  Plugin: vite:import-analysis

When I pnpm i, then it shows the above issue. Vite version is 3.0.8 and Svelte version is 3.49.0 so how can fix this issue?

2reactions
mquandallecommented, Dec 3, 2022

I encounter this issue with vite 2.9+ and it wasn’t the case before. Defining an entry point in the “main” field of package.json indeed solve the issue.

But since I’m already defining my two entry points in optimizeDeps.entries I think it shouldn’t be necessary to include them as well in the package.json

Read more comments on GitHub >

github_iconTop Results From Across the Web

'package.json' is not under 'rootDir' - Stack Overflow
We'll treat the src directory and the root directory containing package.json as separate projects. Each will have its own tsconfig file.
Read more >
Module Resolution - Parcel
Module resolution can be relative to the: entry root: the directory of the entrypoint specified to Parcel, or the shared root (common parent...
Read more >
CommonJS modules | Node.js v19.3.0 Documentation
CommonJS modules are the original way to package JavaScript code for Node.js. ... in the directory, or if the "main" entry is missing...
Read more >
Resolve | webpack
import Test1 from 'xyz'; // Exact match, so path/to/file.js is resolved and ... Condition names for exports field which defines entry points of...
Read more >
Building for Production - Vite
When it is time to deploy your app for production, simply run the vite build command. By default, it uses <root>/index.html as the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found