Subwaytime / vite-aliases

Alias auto generation for Vite
https://www.npmjs.com/package/vite-aliases
MIT License
213 stars 13 forks source link

No known conditions for "." specifier in "vite-aliases" package #54

Closed zqq-nuli closed 1 year ago

zqq-nuli commented 1 year ago

node_modules/.pnpm/registry.npmmirror.com+esbuild@0.16.17/node_modules/esbuild/lib/main.js:1365:27: ERROR: [plugin: externalize-deps] Failed to resolve entry for package "vite-aliases". The package may have incorrect main/module/exports specified in its package.json: No known conditions for "." specifier in "vite-aliases" package at failureErrorWithLog

zqq-nuli commented 1 year ago

"dependencies": { "vite": "^4.1.1" }, "devDependencies": { "vite-aliases": "^0.10.0" }

zqq-nuli commented 1 year ago

Failed to resolve entry for package "vite-aliases". The package may have incorrect main/module/exports specified in its package.json: No known conditions for "." specifier in "vite-aliases" package

The only successful way is to import in this way

import { ViteAliases } from "./node_modules/vite-aliases/dist/index"

It seems that the path of "." of export in package.json has not been found, but I compared the package. json of vite and did not find any difference, and did not try to find a solution. I think the problem should not be in package.json

Subwaytime commented 1 year ago

Hey there! Sorry for the late response!

So this issue has been posted multiple times already, but i cant seem to replicate it! I have asked the other issue creators before, if they could provide a test repo and check if the example of vite-aliases runs for them! - It works perfectly for me (using linux), but i unfortunately cannot test against windows anymore..

gpeu commented 1 year ago

This solved it for me:

For those searching this error, it also gets triggered if you don't put type: module in your package.json.

from https://github.com/sveltejs/vite-plugin-svelte/issues/556#issuecomment-1399812785

batje commented 1 year ago

Hey there! Sorry for the late response!

So this issue has been posted multiple times already, but i cant seem to replicate it! I have asked the other issue creators before, if they could provide a test repo and check if the example of vite-aliases runs for them! - It works perfectly for me (using linux), but i unfortunately cannot test against windows anymore..

It happens on linux, too. One project I have works, the second doesnt. Havent figured out the difference yet.

Subwaytime commented 1 year ago

This issue seems to appear only if you dont have

"type": "module"

in your package.json.