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

import-meta-resolve dependency breaks Yarn 4 Plug'n'Play/Zero-installs #11578

Open
maximdeclercq opened this issue Jan 10, 2024 · 3 comments · May be fixed by #12532
Open

import-meta-resolve dependency breaks Yarn 4 Plug'n'Play/Zero-installs #11578

maximdeclercq opened this issue Jan 10, 2024 · 3 comments · May be fixed by #12532

Comments

@maximdeclercq
Copy link

maximdeclercq commented Jan 10, 2024

Describe the bug

Yarn 4 Plug'n'Play/Zero-installs were supported up until SvelteKit 2.0.7.

Downgrading with yarn add -D @sveltejs/[email protected] resolves any issue with Yarn 4 Plug'n'Play/Zero-installs.

Ever since SvelteKit 2.0.8, Plug'n'Play/Zero-installs are no longer supported due to the incompatibility with import-meta-resolve.

Reproduction

  1. Create a new project with create-svelte
$ yarn create svelte example && cd example
yarn create v1.22.21
[1/4] Resolving packages...
⠁ (node:2276661) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "[email protected]" with binaries:
      - create-svelte
[#######] 7/7
create-svelte version 6.0.6

┌  Welcome to SvelteKit!
│
◇  Which Svelte app template?
│  Skeleton project
│
◇  Add type checking with TypeScript?
│  Yes, using TypeScript syntax
│
◇  Select additional options (use arrow keys/space bar)
│  none
│
└  Your project is ready!

✔ Typescript
  Inside Svelte components, use <script lang="ts">

Install community-maintained integrations:
  https://github.com/svelte-add/svelte-add

Next steps:
  1: cd platform
  2: yarn install
  3: git init && git add -A && git commit -m "Initial commit" (optional)
  4: yarn run dev -- --open

To close the dev server, hit Ctrl-C

Stuck? Visit us at https://svelte.dev/chat
Done in 6.44s.
  1. Enable Yarn 4 Plug'n'Play/Zero-install and install packages
$ corepack enable
$ yarn set version stable
$ yarn config set nodeLinker pnp
$ yarn install
  1. Run development server
$ yarn dev

Logs

error when starting dev server:
Error: Cannot find package '@sveltejs/vite-plugin-svelte' imported from /home/user/example/dummy.js
    at __node_internal_ (file:///home/user/.yarn/berry/cache/import-meta-resolve-npm-4.0.0-13a6ef4fd3-10c0.zip/node_modules/import-meta-resolve/lib/errors.js:431:11)
    at new NodeError (file:///home/user/.yarn/berry/cache/import-meta-resolve-npm-4.0.0-13a6ef4fd3-10c0.zip/node_modules/import-meta-resolve/lib/errors.js:374:5)
    at packageResolve (file:///home/user/.yarn/berry/cache/import-meta-resolve-npm-4.0.0-13a6ef4fd3-10c0.zip/node_modules/import-meta-resolve/lib/resolve.js:1038:9)
    at moduleResolve (file:///home/user/.yarn/berry/cache/import-meta-resolve-npm-4.0.0-13a6ef4fd3-10c0.zip/node_modules/import-meta-resolve/lib/resolve.js:1101:20)
    at defaultResolve (file:///home/user/.yarn/berry/cache/import-meta-resolve-npm-4.0.0-13a6ef4fd3-10c0.zip/node_modules/import-meta-resolve/lib/resolve.js:1266:15)
    at Module.resolve (file:///home/user/.yarn/berry/cache/import-meta-resolve-npm-4.0.0-13a6ef4fd3-10c0.zip/node_modules/import-meta-resolve/index.js:32:12)
    at resolve_peer_dependency (file:///home/user/example/.yarn/unplugged/@sveltejs-kit-virtual-93c8ce76c9/node_modules/@sveltejs/kit/src/exports/vite/index.js:132:29)
    at sveltekit (file:///home/user/example/.yarn/unplugged/@sveltejs-kit-virtual-93c8ce76c9/node_modules/@sveltejs/kit/src/exports/vite/index.js:167:27)
    at async Promise.all (index 0)
    at async asyncFlatten (file:///home/user/example/.yarn/__virtual__/vite-virtual-75c9d0056a/4/.yarn/berry/cache/vite-npm-5.0.11-d5457a8b86-10c0.zip/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:12894:16)
    at async resolveConfig (file:///home/user/example/.yarn/__virtual__/vite-virtual-75c9d0056a/4/.yarn/berry/cache/vite-npm-5.0.11-d5457a8b86-10c0.zip/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:67863:29)
    at async _createServer (file:///home/user/example/.yarn/__virtual__/vite-virtual-75c9d0056a/4/.yarn/berry/cache/vite-npm-5.0.11-d5457a8b86-10c0.zip/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:60327:20)
    at async CAC.<anonymous> (file:///home/user/example/.yarn/__virtual__/vite-virtual-75c9d0056a/4/.yarn/berry/cache/vite-npm-5.0.11-d5457a8b86-10c0.zip/node_modules/vite/dist/node/cli.js:764:24)

System Info

System:
    OS: Linux 6.6 CachyOS Linux
    CPU: (20) x64 13th Gen Intel(R) Core(TM) i9-13900H
    Memory: 20.99 GB / 30.98 GB
    Container: Yes
    Shell: 3.7.0 - /bin/fish
  Binaries:
    Node: 21.5.0 - /tmp/xfs-6a97206b/node
    Yarn: 4.0.2 - /tmp/xfs-6a97206b/yarn
  npmPackages:
    @sveltejs/adapter-auto: ^3.0.0 => 3.1.0
    @sveltejs/kit: ^2.0.0 => 2.2.0
    @sveltejs/vite-plugin-svelte: ^3.0.0 => 3.0.1
    svelte: ^4.2.7 => 4.2.8
    vite: ^5.0.3 => 5.0.11

Severity

annoyance

Additional Information

No response

@Rich-Harris
Copy link
Member

Yarn PnP is broken, and we don't support it — if it ever worked, it was by accident. It is a frequent source of misery for OSS maintainers, and we strongly recommend using nodeLinker: 'node-modules' or (better) just using npm/pnpm.

@rob-balfre
Copy link

I'm using pnpm and getting same error after bumping from v2 to v2.3

Error: Cannot find package '@sveltejs/vite-plugin-svelte' imported from /Users/.../kit/dummy.js

@rob-balfre
Copy link

Solved it... I didn't have this dev dependency:

"@sveltejs/vite-plugin-svelte": "^3.0.1",

So I was getting the dummy.js error posted above (not the nicest error!).

I had missed this migration step for kit v2:

@sveltejs/vite-plugin-svelte@3 (this is now required as a peerDependency of SvelteKit — previously it was directly depended upon)

dummdidumm added a commit that referenced this issue Aug 1, 2024
…t package

Simplifies code a bit around usage locations in our own code, and solves some issues people may have with their setups
closes #11578
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants