Skip to content

Error of Unknown file extension ".svelte" in SvelteKit #375

@alanko0511

Description

@alanko0511

Describe the bug
I followed steps in the SvelteKit installation, but when I run npm run dev, whatever what components are used, there is always an error of Unknown file extension ".svelte.... After the first load, the issue seems to be gone, but if I run npm run build and npm run preview to build the website, the error happens with 500 Cannot find package '/.../node_modules/@smui/button/'

For example when I used buttons, the error is:
Unknown file extension ".svelte" for /.../node_modules/@smui/button/dist/Button.svelte

To Reproduce

  1. npm init svelte@next users Which Svelte app template? > Skeleton project, Use TypeScript? Yes
  2. Follow steps here without dark mode support.
  3. Replace content in index.svelte with button example svelte

package.json

{
  "name": "project",
  "version": "0.0.1",
  "scripts": {
    "dev": "svelte-kit dev",
    "build": "svelte-kit build",
    "package": "svelte-kit package",
    "preview": "svelte-kit preview",
    "check": "svelte-check --tsconfig ./tsconfig.json",
    "check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
    "prepare": "npm run smui-theme",
    "smui-theme": "smui-theme compile static/smui.css -i src/theme"
  },
  "devDependencies": {
    "@smui/button": "^6.0.0-beta.4",
    "@smui/card": "^6.0.0-beta.4",
    "@sveltejs/adapter-auto": "next",
    "@sveltejs/kit": "next",
    "smui-theme": "^6.0.0-beta.4",
    "svelte": "^3.44.0",
    "svelte-check": "^2.2.6",
    "svelte-preprocess": "^4.9.4",
    "tslib": "^2.3.1",
    "typescript": "^4.4.3"
  },
  "type": "module"
}

svelte.config.js

import adapter from '@sveltejs/adapter-auto';
import preprocess from 'svelte-preprocess';

/** @type {import('@sveltejs/kit').Config} */
const config = {
	// Consult https://github.com/sveltejs/svelte-preprocess
	// for more information about preprocessors
	preprocess: preprocess(),

	kit: {
		adapter: adapter(),

		// hydrate the <div id="svelte"> element in src/app.html
		target: '#svelte'
	}
};

export default config;

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions