nuxt / nuxt

The Intuitive Vue Framework.
https://nuxt.com
MIT License
54.95k stars 5.03k forks source link

ERROR Pre-transform error: path should be a path.relative()d string, but got "c:/project/test/plugin-vue:export-helper" #25941

Open Chitzi opened 8 months ago

Chitzi commented 8 months ago

Environment

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
github-actions[bot] commented 8 months ago

Would you be able to provide a reproduction? 🙏

More info ### Why do I need to provide a reproduction? Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making. ### What will happen? If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritize it based on its severity and how many people we think it might affect. If `needs reproduction` labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it. ### How can I create a reproduction? We have a couple of templates for starting with a minimal reproduction: 👉 https://stackblitz.com/github/nuxt/starter/tree/v3-stackblitz 👉 https://codesandbox.io/s/github/nuxt/starter/v3-codesandbox A public GitHub repository is also perfect. 👌 Please ensure that the reproduction is as **minimal** as possible. See more details [in our guide](https://nuxt.com/docs/community/reporting-bugs/#create-a-minimal-reproduction). You might also find these other articles interesting and/or helpful: - [The Importance of Reproductions](https://antfu.me/posts/why-reproductions-are-required) - [How to Generate a Minimal, Complete, and Verifiable Example](https://stackoverflow.com/help/minimal-reproducible-example)
Kalinjuk commented 8 months ago

I also have this problem.

d:\Projects\NuxtStarter>npx nuxi init test

√ Which package manager would you like to use? npm o Installing dependencies... 19:07:33

postinstall nuxt prepare

√ Types generated in .nuxt 19:09:22

added 731 packages, and audited 733 packages in 2m

121 packages are looking for funding run npm fund for details

found 0 vulnerabilities √ Installation completed. 19:09:22

√ Initialize git repository? No 19:10:09 ✨ Nuxt project has been created with the v3 template. Next steps: › cd test 19:10:09 › Start development server with npm run dev 19:10:09

d:\Projects\NuxtStarter> d:\Projects\NuxtStarter> d:\Projects\NuxtStarter>cd test

d:\Projects\NuxtStarter\test>npx nuxi dev Nuxt 3.10.3 with Nitro 2.8.1 19:10:32 [get-port] Unable to find an available port (tried 3000 on host "localhost"). Using alternative port 3001. 19:10:32 19:10:32 ➜ Local: http://localhost:3001/ ➜ Network: use --host to expose

➜ DevTools: press Shift + Alt + D in the browser (v1.0.8) 19:10:40

WARN Slow module @nuxt/devtools took 5061.65ms to setup. 19:10:40

[19:10:45] ERROR Pre-transform error: path should be a path.relative()d string, but got "d:/Projects/NuxtStarter/test/plugin-vue:export-helper"

[19:10:46] ERROR Pre-transform error: path should be a path.relative()d string, but got "d:/Projects/NuxtStarter/test/plugin-vue:export-helper" (x2)

[19:10:46] ERROR Pre-transform error: path should be a path.relative()d string, but got "d:/Projects/NuxtStarter/test/plugin-vue:export-helper" (x3)

[19:10:46] ERROR Pre-transform error: path should be a path.relative()d string, but got "d:/Projects/NuxtStarter/test/plugin-vue:export-helper" (x4)

[19:10:46] ERROR Pre-transform error: path should be a path.relative()d string, but got "d:/Projects/NuxtStarter/test/plugin-vue:export-helper" (x5)

[19:10:46] ERROR Pre-transform error: path should be a path.relative()d string, but got "d:/Projects/NuxtStarter/test/plugin-vue:export-helper" (x6)

[19:10:46] ERROR Pre-transform error: path should be a path.relative()d string, but got "d:/Projects/NuxtStarter/test/plugin-vue:export-helper" (x7)

[19:10:46] ERROR Pre-transform error: path should be a path.relative()d string, but got "d:/Projects/NuxtStarter/test/plugin-vue:export-helper" (x8)

[19:10:46] ERROR Pre-transform error: path should be a path.relative()d string, but got "d:/Projects/NuxtStarter/test/plugin-vue:export-helper" (x9)

[19:10:46] ERROR Pre-transform error: path should be a path.relative()d string, but got "d:/Projects/NuxtStarter/test/plugin-vue:export-helper" (x10)

i Vite server warmed up in 1592ms 19:10:47 i Vite client warmed up in 1848ms 19:10:47 √ Nitro built in 682 ms nitro 19:10:48

Chitzi commented 8 months ago

Would you be able to provide a reproduction? 🙏

More info

I've wrote how to reproduce.

npx nuxi@latest init test

# (options npm and yes for github)

cd test
npm run dev

I've tried with an empty project and I've got the error.

webcodepl commented 8 months ago

I have the same error. I installed on two computers, both: x64, windows 10 pro, 22h2, node v20.11.1., but problem is only on one of them.

Result of http://localhost:3000

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

webcodepl commented 8 months ago

I don;t know if something was updated in the meantime, but i installed it again and now works.

Kalinjuk commented 8 months ago

In my case, the problem was solved by running the node as an administrator

devjkuna commented 8 months ago

Run 'npm run dev' or 'yarn dev' from terminal in your IDE. Not in windows/cmder terminal

jerell2isekai commented 8 months ago

same problem here if I am using Cmder.

howbizarre commented 8 months ago

If you set devtools to false, it will remove the error...

export default defineNuxtConfig({
  devtools: { enabled: false }
});

In my case error 500 is returned if devtools is active

500
[vite-node] [plugin:nuxt:components:imports] [VITE_ERROR] /@fs/C:/Users/user/AppData/Roaming/npm/node_modules/@nuxt/devtools/dist/runtime/plugins/devtools.server.mjs

import { defineNuxtPlugin } from "#app";
import { useState } from "#imports";
export default defineNuxtPlugin(() => {
  const state = useState("__nuxt_devtools__", () => ({}));
  state.value = {
    timeSsrStart: Date.now()
  };
});

jerell2isekai commented 8 months ago

If you set devtools to false, it will remove the error...

export default defineNuxtConfig({
  devtools: { enabled: false }
});

Unfortunately, it does not work for me. but Thanks anyway.

gpproton commented 8 months ago

Also experincing the same issues while i was trying to quickly use a basic templete

webcodepl commented 8 months ago

Today problem came back again trying with an empty project.

webcodepl commented 8 months ago

I found that it happens when "npm run dev" is run from windows cmd terminal. Running from windows powershell works ok.

LuisBrescia commented 7 months ago
500
[vite-node] [plugin:nuxt:components:imports] [VITE_ERROR] /@fs/C:/Users/user/AppData/Roaming/npm/node_modules/@nuxt/devtools/dist/runtime/plugins/devtools.server.mjs

import { defineNuxtPlugin } from "#app";
import { useState } from "#imports";
export default defineNuxtPlugin(() => {
  const state = useState("__nuxt_devtools__", () => ({}));
  state.value = {
    timeSsrStart: Date.now()
  };
});

If you set devtools to false, it will remove the error...

export default defineNuxtConfig({
  devtools: { enabled: false }
});

In my case error 500 is returned if devtools is active

500
[vite-node] [plugin:nuxt:components:imports] [VITE_ERROR] /@fs/C:/Users/user/AppData/Roaming/npm/node_modules/@nuxt/devtools/dist/runtime/plugins/devtools.server.mjs

import { defineNuxtPlugin } from "#app";
import { useState } from "#imports";
export default defineNuxtPlugin(() => {
  const state = useState("__nuxt_devtools__", () => ({}));
  state.value = {
    timeSsrStart: Date.now()
  };
});
  • Operating System: Windows_NT
  • Node Version: v18.17.0
  • Nuxt Version: 3.10.3
  • CLI Version: 3.10.1
  • Nitro Version: 2.9.1
  • Package Manager: npm@10.3.0
  • Builder: -
  • User Config: devtools
  • Runtime Modules: -
  • Build Modules: -

Same error here

Marcoru97 commented 7 months ago

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 returns C:/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 package nuxt._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 😅

hdqbasith commented 7 months ago

In my case

Check Task Manager There are some programs running under "Terminal"

  1. OpenConsole.exe
  2. cmd.exe
  3. WindowsTerminal.exe

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

Tarabass commented 7 months ago

In my case

Check Task Manager There are some programs running under "Terminal"

1. OpenConsole.exe

2. cmd.exe

3. WindowsTerminal.exe

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

You're my day saver :)

HijackHornet commented 7 months ago

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.

hdqbasith commented 7 months ago

Found the culprit

Use Capital for drive letter "C:\" "D:\" If you use "c:\" or "d:\" it won't work

jerell2isekai commented 7 months ago

Found the culprit

Use Capital for drive letter "C:" "D:" If you use "c:" or "d:" it won't work

Confirmed the same test result will work by changing drive letter "d:" to capital "D:" .

iamlaristo commented 7 months ago

Any solution for people using Cmder? Is there a way to use Powershell automatically when the command is npm run or bun run to make sure there's no issue?

Or even better, is it possible to fix the issue so it still works with Cmder/cmd mode?

donPuerto commented 6 months ago

Add devtool in your module

modules: [
    '@nuxt/devtools',
  ],

ie

  // https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  devtools: { enabled: true },
  modules: [
    '@nuxt/devtools',
  ],
})
tamaszentai commented 5 months ago

Add devtool in your module

modules: [
    '@nuxt/devtools',
  ],

ie

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: { enabled: true },
modules: [
  '@nuxt/devtools',
],
})

This is working, thank you!

danielroe commented 1 month ago

This is probably caused by a global install of @nuxt/devtools on a different drive than your project.

It probably highlights an upstream issue somewhere we can resolve.