vitest icon indicating copy to clipboard operation
vitest copied to clipboard

Could not read source map when debugging test

Open phifa opened this issue 2 years ago • 3 comments

Describe the bug

Could not read source map for @vite/env: ENOENT: no such file or directory.

Reproduction

Set up a new remix project like so: npx create-remix --template remix-run/indie-stack. Then add the debugger like described here: https://vitest.dev/guide/debugging.html

When now opening the debugger, the debug console says this:

Could not read source map for file:///Users/user/remix-indie/remix/@vite/env: ENOENT: no such file or directory, open '/Users/user/remix-indie/remix/@vite/env.mjs.map'

System Info

npmPackages:
    @vitejs/plugin-react: ^1.3.2 => 1.3.2
    vite: ^2.9.10 => 2.9.15
    vitest: ^0.14.1 => 0.14.2
  System:
    OS: macOS 12.5.1, M1

Used Package Manager

yarn

Validations

phifa avatar Aug 26 '22 06:08 phifa

I am running into the same issue, but I am using vite with a vanilla TypeScript file.

Could not read source map for file:///Users/johnsolly/Documents/code/algoTraining/TypeScript/@vite/env: ENOENT: no such file or directory, open '/Users/johnsolly/Documents/code/algoTraining/TypeScript/@vite/env.mjs.map'

I get this error whenever I try to run a test using vscode via the vitest vscode plugin. The test appears to run, but I still get an error every time I debug a test.

MacOS Monterey VScode Vitest vscode plugin 0.2.29 vscode 1.71.2

Package.json

{
  "name": "typescript",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "test": "vitest",
    "coverage": "vitest run --coverage",
    "dev": "vite",
    "build": "tsc && vite build",
    "preview": "vite preview"
  },
  "devDependencies": {
    "@types/node": "^18.7.16",
    "@typescript-eslint/eslint-plugin": "^5.36.2",
    "@typescript-eslint/parser": "^5.36.2",
    "@vitest/coverage-c8": "^0.23.1",
    "cypress": "^10.7.0",
    "eslint": "^8.23.0",
    "eslint-config-prettier": "^8.5.0",
    "eslint-plugin-extra-rules": "^0.0.0-development",
    "eslint-plugin-prettier": "^4.2.1",
    "eslint-plugin-tsdoc": "^0.2.16",
    "husky": "^8.0.1",
    "jsdom": "^20.0.0",
    "lint-staged": "^13.0.3",
    "prettier": "2.7.1",
    "typescript": "^4.8.3",
    "vite": "^3.0.9",
    "vitest": "^0.23.1"
  }
}

image

jsolly avatar Sep 19 '22 06:09 jsolly

Same error.

rigogsilva avatar Nov 16 '22 18:11 rigogsilva

I had this bug too, if someone else has this bug, try this workaround:

I had a min.js file which had a comment in it like this: //# sourceMappingURL=some.file.min.js.map

^ That was what triggered the bug, I removed it and vitest coverage stopped crashing. What I find truly a bug is that this file was explicitly excluded from my vitest config -> test -> exclude section.

Looks like the same issue as here: https://github.com/vitest-dev/vitest/discussions/4754

ldevoco avatar Jan 25 '24 16:01 ldevoco