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

Initialize SvelteKit project with Yarn #1557

Closed
alecandido opened this issue May 25, 2021 · 2 comments
Closed

Initialize SvelteKit project with Yarn #1557

alecandido opened this issue May 25, 2021 · 2 comments

Comments

@alecandido
Copy link

Describe the bug
I was not able to initialize with yarn, i.e. the command yarn create svelte@next foo is failing.

To Reproduce

  • yarn: 2.4.1
  • node: v16.1.0

Then run yarn create svelte@next foo.

Expected behavior
Initialize the same way of npm init svelte@next foo

Stacktraces

yarn output

➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed in 1s 638ms
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed
➤ YN0000: Done in 1s 699ms

(node:66799) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use node --trace-warnings ... to show where the warning was created)
/home/alessandro/.yarn/berry/cache/create-svelte-npm-2.0.0-next.71-3c988c4861-7.zip/node_modules/create-svelte/bin.js:2
import fs from 'fs';

^^^^^^
SyntaxError: Cannot use import statement outside a module
at Object.compileFunction (node:vm:355:18)
at wrapSafe (node:internal/modules/cjs/loader:1039:15)
at Module._compile (node:internal/modules/cjs/loader:1073:27)
at Object.Module.extensions..js (node:internal/modules/cjs/loader:1138:10)
at Module.load (node:internal/modules/cjs/loader:989:32)
at Function.external_module
.Module._load (/tmp/xfs-14e6a52a/dlx-66788/.pnp.js:4968:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
at node:internal/main/run_main_module:17:47

Severity
I have found a workaround and I can still use npm, so low.

Additional context
I found a workaround: searching on stackoverflow I found a related question and somewhere else (I don't remember where, most likely in yarn documentation) I get the second bit of the equation and the two things together made the command working:

  1. add immediately a package.json
{
   "type": "module"
}
  1. add the following line in .yarnrc.yml
nodeLinker: "node-modules"

I actually don't know how bad is what I'm doing, it looks to me that I'm able to revert the two tricks right after, and I hope the thing should not be incompatible overall. But I just know this way it's running, and doing what expected.

@benmccann
Copy link
Member

We don't support Yarn and recommend against using it: https://kit.svelte.dev/faq#integrations

@alecandido
Copy link
Author

alecandido commented May 25, 2021

Sorry to have opened another PR, keep searching I even found an older issue #993, unfortunately I just found workarounds before the disclaimer... (at least the former workaround fully works at the time of writing)

I will follow the advice and drop yarn for svelte.

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

No branches or pull requests

2 participants