Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐞] Path Resolution Issue: '~/' Prefix Not Resolving Modules Properly #4948

Closed
kralion opened this issue Aug 16, 2023 · 26 comments
Closed
Labels
COMMUNITY: good first issue Good for newcomers COMMUNITY: PR is welcomed We think it's a good feature to have but would love for the community to help with the PR for it STATUS-2: missing info Incomplete issue/pr template or missing important information TYPE: bug Something isn't working WAITING FOR: user Further information is requested from the issue / pr opener

Comments

@kralion
Copy link

kralion commented Aug 16, 2023

Which component is affected?

Qwik Runtime

Describe the bug

I am running npm start for the first time, What i expect is the first renfer of Qwik. What actually happening is
image

Reproduction

https://github.com/Dv-Joan/qwik-issue-repo.git

Steps to reproduce

Create the Basic app template followed by npm install and finally npm start

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
    Memory: 2.11 GB / 7.85 GB
 Binaries:
    Node: 18.17.1 - C:\Program Files\nodejs\node.EXE
    npm: 9.8.1 - C:\Program Files\nodejs\npm.CMD
 Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (115.0.1901.203)
    Internet Explorer: 11.0.19041.1566

Additional Information

Files are there
image
This is my tsconfig.json
image
and i tried this modification
image
but it doesn't work. I have to use this type of import
image
to work but on all files to make it work

@kralion kralion added STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working labels Aug 16, 2023
@kralion kralion changed the title [🐞] [🐞] Path Resolution Issue: '~/' Prefix Not Resolving Modules Properly Aug 16, 2023
@sarvex
Copy link

sarvex commented Aug 20, 2023

I am facing the same issue

@mhevery
Copy link
Contributor

mhevery commented Aug 21, 2023

Is this a windows issue?

@kralion
Copy link
Author

kralion commented Aug 22, 2023

Is this a windows issue?

Hi Miško
Confirmed, is a windows issue

@mhevery mhevery added COMMUNITY: good first issue Good for newcomers COMMUNITY: PR is welcomed We think it's a good feature to have but would love for the community to help with the PR for it and removed STATUS-1: needs triage New issue which needs to be triaged labels Aug 23, 2023
@mhevery
Copy link
Contributor

mhevery commented Aug 23, 2023

It would be great if someone with a Windows machine could look into it.

@Axibord
Copy link

Axibord commented Sep 11, 2023

It would be great if someone with a Windows machine could look into it.

I couldn't reproduce the bug on Windows 11 (in/out WSL) everything works fine. Maybe W10 path resolution is different

System info

OS: Windows 11 Pro
Version: 22H2
OS build: 22621.2215
Processor: AMD Ryzen 9 7900X 12-Core 4.70 GHz

node: 18.16.0
npm: 9.6.5

@sarvex
Copy link

sarvex commented Sep 12, 2023

@mhevery the problem is easily reproducible on Windows 11 in powershell. The path resolution is superceded by the $HOME variable in Windows 11

OS: Windows 11 Pro
Version: 22H2
OS build: 22621.2215
Processor: Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz   2.30 GHz

node: 20.6.1
npm: 9.8.1
pnpm: 8.7.4

Here is the detailed error log on Windows 11 Powershell

07:31:17 [vite] warning: Parsing error: ESLint was configured to run on `D:\Sources\qwik-app\src\routes\layout.tsx` using `parserOptions.project`: <tsconfigRootDir>/tsconfig.json
However, that TSConfig does not include this file. Either:
- Change ESLint's list of included files to not include this file
- Change that TSConfig to include this file
- Create a new TSConfig that includes this file and include it in your parserOptions.project
See the typescript-eslint docs for more info: https://typescript-eslint.io/linting/troubleshooting#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file
  Plugin: vite-plugin-qwik
  File: D:/Sources/qwik-app/src/routes/layout.tsx:undefined:undefined
Failed to load url ~/components/starter/header/header (resolved id: ~/components/starter/header/header) in D:/Sources/qwik-app/src/routes/layout.tsx. Does the file exist?
Failed to load url ~/components/starter/footer/footer (resolved id: ~/components/starter/footer/footer) in D:/Sources/qwik-app/src/routes/layout.tsx. Does the file exist?
07:31:20 [vite] Error when evaluating SSR module C:/Users/Yoga/Sources/qwik-app/src/routes/layout.tsx: failed to import "~/components/starter/header/header"
|- Error: Cannot find module '~/components/starter/header/header' imported from 'D:/Sources/qwik-app/src/routes/layout.tsx'
    at nodeImport (file:///D:/Sources/qwik-app/node_modules/vite/dist/node/chunks/dep-3b8eb186.js:55956:25)
    at ssrImport (file:///D:/Sources/qwik-app/node_modules/vite/dist/node/chunks/dep-3b8eb186.js:55858:30)
    at eval (D:/Sources/qwik-app/src/routes/layout.tsx:11:37)
    at async instantiateModule (file:///D:/Sources/qwik-app/node_modules/vite/dist/node/chunks/dep-3b8eb186.js:55920:9)

07:31:20 [vite] Internal server error: Cannot find module '~/components/starter/header/header' imported from 'D:/Sources/qwik-app/src/routes/layout.tsx'
  File: /Sources/qwik-app/src/routes/layout.tsx:11:37
      at nodeImport (file:///D:/Sources/qwik-app/node_modules/vite/dist/node/chunks/dep-3b8eb186.js:55956:25)
      at ssrImport (file:///D:/Sources/qwik-app/node_modules/vite/dist/node/chunks/dep-3b8eb186.js:55858:30)
      at eval (D:/Sources/qwik-app/src/routes/layout.tsx:11:37)
      at async instantiateModule (file:///D:/Sources/qwik-app/node_modules/vite/dist/node/chunks/dep-3b8eb186.js:55920:9)
07:32:38 [vite] Internal server error: Cannot find module '~/components/starter/header/header' imported from 'D:/Sources/qwik-app/src/routes/layout.tsx'
  File: /Sources/qwik-app/src/routes/layout.tsx:11:37
      at nodeImport (file:///D:/Sources/qwik-app/node_modules/vite/dist/node/chunks/dep-3b8eb186.js:55956:25)
      at ssrImport (file:///D:/Sources/qwik-app/node_modules/vite/dist/node/chunks/dep-3b8eb186.js:55858:30)
      at eval (D:/Sources/qwik-app/src/routes/layout.tsx:11:37)
      at async instantiateModule (file:///D:/Sources/qwik-app/node_modules/vite/dist/node/chunks/dep-3b8eb186.js:55920:9) (x2)

The application runs fine on WSL2

@Charlygraphy23
Copy link
Contributor

I will look into this issue. First, need to identify if the issue is windows only.

@Charlygraphy23
Copy link
Contributor

Reproduction
https://github.com/Dv-Joan/qwik-issue-repo.git

Hi your reproduction link is not working, can you provide a working one.

@sarvex
Copy link

sarvex commented Oct 16, 2023

For me, the problem is with the FS module which is unable to follow the symlink in Windows.

@mhevery
Copy link
Contributor

mhevery commented Oct 19, 2023

If someone with Windows could try to create a fix I would be happy to provide support.

@DerTimonius
Copy link

Currently trying to reproduce this issue on Windows 11 with the steps provided in the description:

  • creating a new app with the basic template
  • change the import of a component from a relative to absolute path.
  • start the app
    • no error with git bash
    • no error with Powershell
    • no error with CMD

Maybe it's possible that the issue is either resolved or an isolated issue with Windows 10? @Dv-Joan

@sarvex
Copy link

sarvex commented Nov 4, 2023

@DerTimonius @mhevery the issue is with the fs package being unable to handle Windows symlinks.

@gioboa
Copy link
Member

gioboa commented Nov 4, 2023

@sarvex Is there a specific fs issue related to this problem? Can you post here the link?

@sarvex
Copy link

sarvex commented Nov 5, 2023

@gioboa

I can put in the steps to reproduce the issue, and the issue is not only with Qwik but also with other frameworks that create project files like Astro or Svelte

  1. Create a symlink folder in Windows i.e. something like %USER_PROFILE%\Sources to D:\Sources
  2. Create a new project in %USER_PROFILE%\Sources using the pnpm create Qwik
  3. Run the project

You will see problems like files not found, CSS not loaded, etc...

@gioboa
Copy link
Member

gioboa commented Nov 5, 2023

Are you using powershell or WSL2?

@wmertens
Copy link
Member

wmertens commented Nov 5, 2023

@sarvex Looks like nodejs and symlinking on windows isn't a great combo? nodejs/node#18518

I presume that the symlink you created is an actual symlink and not a .lnk file?

@sarvex
Copy link

sarvex commented Nov 6, 2023

@gioboa I am using PowerShell

@wmertens Yeah, I recently realized that symlinking is bad, but the problem only comes with 'pnpm create' and not with any other use cases. Also, I am using the actual symlink using 'New-Item SymbolicLink` command

@DerTimonius
Copy link

@sarvex I used npm and yarn fyi

@sarvex
Copy link

sarvex commented Nov 7, 2023

@DerTimonius the issue is not with the package manager, but rather with symlink. if you try again you will be able to reproduce the issue.

@kralion
Copy link
Author

kralion commented Dec 23, 2023

Reproduction

https://github.com/Dv-Joan/qwik-issue-repo.git

Hi your reproduction link is not working, can you provide a working one.

Sorry man, I deleted the repo

@gioboa
Copy link
Member

gioboa commented Dec 26, 2023

Do you have the same issue with the latest version of Qwik (v. 1.3.1) ?

@kralion
Copy link
Author

kralion commented Dec 26, 2023

Do you have the same issue with the latest version of Qwik (v. 1.3.1) ?

It works well with 'npm ...' but with 'pnpm .... ' i have this error

Console Screenshot

@gioboa
Copy link
Member

gioboa commented Dec 26, 2023

Did you remove node_modules and install the deps again with pnpm?

@kralion
Copy link
Author

kralion commented Dec 26, 2023

Did you remove node_modules and install the deps again with pnpm?

No, I just follow this docs for pnpm

image

@gioboa
Copy link
Member

gioboa commented Jun 17, 2024

@kralion Did you solve this issue or is it still open?

@gioboa gioboa added WAITING FOR: user Further information is requested from the issue / pr opener STATUS-2: missing info Incomplete issue/pr template or missing important information labels Jun 17, 2024
Copy link
Contributor

Hello @kralion. Please provide the missing information requested above.
Issues marked with STATUS-2: missing info will be automatically closed if they have no activity within 14 days.
Thanks 🙏

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
COMMUNITY: good first issue Good for newcomers COMMUNITY: PR is welcomed We think it's a good feature to have but would love for the community to help with the PR for it STATUS-2: missing info Incomplete issue/pr template or missing important information TYPE: bug Something isn't working WAITING FOR: user Further information is requested from the issue / pr opener
Projects
None yet
Development

No branches or pull requests

8 participants