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

Vitest >=0.31.2 throws error cannot find package '__sveltekit' in SvelteKit project #3483

Closed
6 tasks done
danieldiekmeier opened this issue May 31, 2023 · 2 comments · Fixed by #3485
Closed
6 tasks done

Comments

@danieldiekmeier
Copy link

Describe the bug

After updating to vitest/vite-node 0.31.2, I can't run my tests anymore. Instead, I get this error:

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '__sveltekit' imported from /Users/daniel/dev/node/example/node_modules/@sveltejs/kit/src/runtime/app/environment.js
    at new NodeError (node:internal/errors:399:5)
    at packageResolve (node:internal/modules/esm/resolve:889:9)
    at moduleResolve (node:internal/modules/esm/resolve:938:20)
    at defaultResolve (node:internal/modules/esm/resolve:1153:11)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:838:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)
    at link (node:internal/modules/esm/module_job:76:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}

I'm not sure if it's related, but there has been a similar looking issue in the past: sveltejs/kit#9162

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-byyurb?file=test%2Fbasic.test.ts,package.json&initialPath=__vitest__/

  • Run npm run test:run to see the error

To make the tests run:

  • Downgrade the vitest version in the package.json to 0.30.1
  • Run npm i
  • Run the tests with npm run test:run, they should pass

System Info

System:
    OS: macOS 13.3.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 9.13 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.16.0 - ~/.asdf/installs/nodejs/18.16.0/bin/node
    Yarn: 1.22.19 - ~/.asdf/installs/nodejs/18.16.0/bin/yarn
    npm: 9.5.1 - ~/.asdf/plugins/nodejs/shims/npm
  Browsers:
    Chrome: 114.0.5735.90
    Edge: 113.0.1774.57
    Firefox: 103.0.2
    Firefox Developer Edition: 113.0
    Safari: 16.4
    Safari Technology Preview: 16.4
  npmPackages:
    @sveltejs/kit: ^1.20.0 => 1.20.0
    @vitest/coverage-c8: ^0.31.2 => 0.31.3
    vite: ^4.3.9 => 4.3.9
    vitest: ^0.31.2 => 0.31.3

Used Package Manager

npm

Validations

@stackblitz
Copy link

stackblitz bot commented May 31, 2023

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@sheremet-va
Copy link
Member

Seems like deps.inline (ssr.noExternal) doesn't work as expected.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants