nuxt: ERROR Pre-transform error: path should be a path.relative()d string, but got "c:/project/test/plugin-vue:export-helper"
Environment
- Operating System: Windows_NT
- Node Version: v20.10.0
- Nuxt Version: 3.10.3
- CLI Version: 3.10.1
- Nitro Version: 2.8.1
- Package Manager: npm@10.2.3
- Builder: -
- User Config: devtools
- Runtime Modules: -
- Build Modules: -
Reproduction
npx nuxi@latest init test
(options npm and yes for github)
cd test npm run dev
Describe the bug
500 [vite-node] [plugin:nuxt:components:imports] [VITE_ERROR] plugin-vue:export-helper
export default (sfc, props) => { const target = sfc.__vccOpts || sfc; for (const [key, val] of props) { target[key] = val; } return target; }
at plugin-vue:export-helper
Additional context
No response
Logs
c:\project\test>npm run dev
> dev
> nuxt dev
Nuxt 3.10.3 with Nitro 2.8.1 8:06:34 PM
8:06:34 PM
➜ Local: http://localhost:3000/
➜ Network: use --host to expose
➜ DevTools: press Shift + Alt + D in the browser (v1.0.8) 8:06:38 PM
[8:06:40 PM] ERROR Pre-transform error: path should be a path.relative()d string, but got "c:/project/test/plugin-vue:export-helper"
[8:06:40 PM] ERROR Pre-transform error: path should be a path.relative()d string, but got "c:/project/test/plugin-vue:export-helper" (x2)
[8:06:40 PM] ERROR Pre-transform error: path should be a path.relative()d string, but got "c:/project/test/plugin-vue:export-helper" (x3)
[8:06:40 PM] ERROR Pre-transform error: path should be a path.relative()d string, but got "c:/project/test/plugin-vue:export-helper" (x4)
[8:06:40 PM] ERROR Pre-transform error: path should be a path.relative()d string, but got "c:/project/test/plugin-vue:export-helper" (x5)
[8:06:40 PM] ERROR Pre-transform error: path should be a path.relative()d string, but got "c:/project/test/plugin-vue:export-helper" (x6)
[8:06:40 PM] ERROR Pre-transform error: path should be a path.relative()d string, but got "c:/project/test/plugin-vue:export-helper" (x7)
[8:06:40 PM] ERROR Pre-transform error: path should be a path.relative()d string, but got "c:/project/test/plugin-vue:export-helper" (x8)
[8:06:40 PM] ERROR Pre-transform error: path should be a path.relative()d string, but got "c:/project/test/plugin-vue:export-helper" (x9)
[8:06:41 PM] ERROR Pre-transform error: path should be a path.relative()d string, but got "c:/project/test/plugin-vue:export-helper" (x10)
i Vite server warmed up in 1565ms 8:06:41 PM
i Vite client warmed up in 1984ms 8:06:42 PM
√ Nitro built in 677 ms nitro 8:06:42 PM
About this issue
- Original URL
- State: open
- Created 4 months ago
- Comments: 21 (1 by maintainers)
I found that it happens when “npm run dev” is run from windows cmd terminal. Running from windows powershell works ok.
Unfortunately, it does not work for me. but Thanks anyway.
Run ‘npm run dev’ or ‘yarn dev’ from terminal in your IDE. Not in windows/cmder terminal
I’ve wrote how to reproduce.
I’ve tried with an empty project and I’ve got the error.
Found the culprit
Use Capital for drive letter "C:" "D:" If you use "c:" or "d:" it won’t work
None of the solution above worked for me within vscode addon. If i run it manually i get no error, but if i click the vscodee ionic plugin to run it, i get the error. I tried both powersheel and cmd settings in vscode.
In my case
Check Task Manager There are some programs running under “Terminal”
If “npm run dev” is called from cmd.exe it will not produce error.
Solution: Change Terminal setting (Ctrl+,) - Startup - Default terminal application - Let Windows Decide or Windows Console Host
Don’t use Windows Terminal
It seems that if the devtools are on C: and the Project is on D: the error occurs.
After some testing I found out that
path.relative("D:/some/path", "C:/some/path")just returnsC:/some/path. The function gets used here: https://github.com/nuxt/nuxt/blob/a3b0b112245a96c0d3e9485ce6c0c74bbf89c497/packages/kit/src/ignore.ts#L24-L28 which causes an exception with in the ignores packagenuxt._ignore.ignores(relativePath)I am not sure why the nuxt devtools need something from C:
C:/Users/user/AppData/Roaming/npm/node_modules/@nuxt/devtools/I removed the folder and tried to install the dev-tools again, which completely fails now 😅
In my case, the problem was solved by running the node as an administrator