kit: Cannot run a newly created project

Describe the bug

After creating a new project and attempting to start it up with npm run dev, I get the following

ENOENT: no such file or directory, open '/home/chris/Projects/community-sveltekit/.svelte-kit/dev/components/.svelte-kit/dev/components/layout.svelte'

Note the duplicate portion of the path .svelte-kit/dev/components

SvelteKit v1.0.0-next.137

Reproduction

https://github.com/chrisolsen/bug-sveltekit

➜ Projects npm init svelte@next community-sveltekit npx: installed 5 in 1.004s

create-svelte version 2.0.0-next.76

Welcome to SvelteKit!

This is beta software; expect bugs and missing features.

If you encounter a problem, open an issue on https://github.com/sveltejs/kit/issues if none exists already.

✔ Which Svelte app template? › Skeleton project ✔ Use TypeScript? … No / Yes ✔ Add ESLint for code linting? … No / Yes ✔ Add Prettier for code formatting? … No / Yes ✔ Copied project files ✔ Added TypeScript support. To use it inside Svelte components, add lang=“ts” to the attributes of a script tag. ✔ Added ESLint. Readme for ESLint and Svelte: https://github.com/sveltejs/eslint-plugin-svelte3 ✔ Added Prettier. General formatting options: https://prettier.io/docs/en/options.html Svelte-specific formatting options: https://github.com/sveltejs/prettier-plugin-svelte#options

Want to add other parts to your code base? Visit https://github.com/svelte-add/svelte-adders, a community project of commands to add particular functionality to Svelte projects

Next steps: 1: cd community-sveltekit 2: npm install (or pnpm install, etc) 3: git init && git add -A && git commit -m “Initial commit” (optional step) 4: npm run dev – --open

============ ➜ community-sveltekit git:(master) npm run dev

~TODO~@0.0.1 dev /home/chris/Projects/community-sveltekit svelte-kit dev

SvelteKit v1.0.0-next.137

local: http://localhost:3000 network: not exposed

Use --host to expose server to other devices on this network

ENOENT: no such file or directory, open ‘/home/chris/Projects/community-sveltekit/.svelte-kit/dev/components/.svelte-kit/dev/components/layout.svelte’ Error: ENOENT: no such file or directory, open ‘/home/chris/Projects/community-sveltekit/.svelte-kit/dev/components/.svelte-kit/dev/components/layout.svelte’ ENOENT: no such file or directory, open ‘/home/chris/Projects/community-sveltekit/.svelte-kit/dev/components/.svelte-kit/dev/components/layout.svelte’ Error: ENOENT: no such file or directory, open ‘/home/chris/Projects/community-sveltekit/.svelte-kit/dev/components/.svelte-kit/dev/components/layout.svelte’

Logs

No response

System Info

➜  community-sveltekit git:(master) npx envinfo --system --binaries --browsers --npmPackages "{svelte,@sveltejs/*,vite}"
npx: installed 1 in 0.753s

  System:
    OS: Linux 4.19 Ubuntu 20.04.2 LTS (Focal Fossa)
    CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
    Memory: 16.92 GB / 25.02 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 12.20.2 - ~/.nvm/versions/node/v12.20.2/bin/node
    npm: 6.14.11 - ~/.nvm/versions/node/v12.20.2/bin/npm
  npmPackages:
    @sveltejs/kit: next => 1.0.0-next.137 
    svelte: ^3.34.0 => 3.40.2

Severity

blocking all usage of SvelteKit

Additional Information

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 13
  • Comments: 38 (10 by maintainers)

Most upvoted comments

Same problem when i create a new skeleton project

Node v14.17.3 SvelteKit v1.0.0-next.137 Svelte v3.34.0

What works for me

  1. npm init svelte@next my-app
  2. cd my-app
  3. replace “svelte”: “^3.34.0” with “svelte”: “3.40.1” in package.json
  4. create __layout.svelte file in src/routes and add <slot></slot>
  5. npm install
  6. npm run dev – --open

As @s0kil suggested, downgrading to svelte: 3.40.1 did the trick.

@joeczar remove “^” from “svelte”: “^3.40.1” then run npm install Screenshot from 2021-07-25 13-29-18

its working for me Screenshot from 2021-07-25 13-28-15

Screenshot from 2021-07-25 13-32-55

Hey Guys, I am facing the same problem, I found a workaround: So, for some reason, SvelteKit is expecting a script tag with at least one valid expression for __layout/page to work.

Example:

Let’s create a new skeleton project. Install the dependencies. Since there is no __layout.svelte file, let’s create one. Add the following contents to the __layout.svelte file:

<script>
	0;
</script>
<slot />

Add the following content to index.svelte file:

<script>
	0;
</script>

<p>
	Try editing <strong>src/routes/index.svelte</strong>
</p>

And this seems to fix this issue somehow. Maybe one of SvelteKit’s maintainers/contributors can throw some light on it.

I am using node 14.17.0.

vite 2.4.4 has been released and the skeleton project works again.

Instead of an error, vite just prints a warning now.

dominikg@mb14:~/develop/reproductions/kit-vite-244$ pnpm ls vite --depth=Infinity
Legend: production dependency, optional only, dev only

~TODO~@0.0.1 /home/dominikg/develop/reproductions/kit-vite-244

devDependencies:
@sveltejs/kit 1.0.0-next.137
├─┬ @sveltejs/vite-plugin-svelte 1.0.0-next.14
│ └── vite 2.4.4 peer
└── vite 2.4.4
dominikg@mb14:~/develop/reproductions/kit-vite-244$ pnpm dev

> ~TODO~@0.0.1 dev /home/dominikg/develop/reproductions/kit-vite-244
> svelte-kit dev


  SvelteKit v1.0.0-next.137

  local:   http://localhost:3000
  network: not exposed

  Use --host to expose server to other devices on this network


Sourcemap for "/home/dominikg/develop/reproductions/kit-vite-244/.svelte-kit/dev/components/layout.svelte" points to missing source files
Sourcemap for "/home/dominikg/develop/reproductions/kit-vite-244/src/routes/index.svelte" points to missing source files


So coming back around to this. Ive tried all the above solutions:

  • use node 12
  • svelte 3.40.1
  • added a __layout.svelte component

FWIW ive delete node_modules and lock file too.

None of the above worked.

EDIT: I didnt explicitly do 3.40.1, i had ^3.40.1. Can confirm this works

EDIT 2: I still needed the __layout.svelte file

Work around is to explicitly use svelte version 3.40.1, "svelte": "3.40.1" in package.json

@eden-lane try to uninstall and reinstall @sveltejs/kit. By doing it you will get it with the latest Vite version. It fixes the error, but shows warnings for now.

@dummdidumm would know better but it seems like that PR adds a missing source entry to the first map when combining sourcemaps to avoid a potential upstream issue in remapping.

The added source entry caused vite to attempt to read the source but the constructed path to that is wrong (see duplicate .svelte-kit/dev/components/ in description) and errors. The next vite version scheduled to be released tomorrow (27.) prints a warning instead, unblocking the use of svelte 3.40.2.

We still need to figure out why that path is wrong, but the warnings from vite might help with that.

TL;DR For those affected by this issue: With vite <= 2.4.3 , use svelte <= 3.40.1 Once vite 2.4.4 (or 2.5.0) has been released, you can update vite and svelte to try again.

I’m running NPM @ 7.20.1, Node @ 14.7.3, with Svelte kit @ 1.0.0-next.137.

When running with Svelte @ 3.40.1 there is no issue but updating to 3.40.2 throws the following:

ENOENT: no such file or directory, open '/Users/Mike/Sites/personal/src/lib/icons/src/lib/icons/GitHub.svelte'

The file in question should be '/Users/Mike/Sites/personal/src/lib/icons/GitHub.svelte' so it appears that part of the path is being duplicated.

The file is referenced as import GitHub from '$lib/icons/GitHub.svelte';. Inside a Footer Svelte component. The footer Svelte component is imported by __layout. Refreshing the app seems to loop through several files throwing a duplicated path.

One thing I’ve noticed is that direct child imports inside of __layout seem to be ok, but anything deeper throws.

As mentioned by others rolling back to 3.40.1 resolves.

Im also getting this error. Clean install (JS, eslint and prettier), skeleton project. Tried switching to node v12 with nvm, still getting error.

Thanks @kampsy! It’s running now.

@kampsy you don’t need to create the __layout.svelte file. Just upgrading Svelte fixes it.

This wasnt true for me. I had to create the __layout.svelte file too. Also, its a downgrade 3.34.0 > 3.40.1. But, tomato, tomato and all that jazz