17

I am new to SvelteKit and have built an initial project from the SvelteKit docs. When the project opens I receive the following error when looking at index.svelte.

Error in svelte.config.js

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@sveltejs/adapter-auto' imported from /Users/.../svelte.config.js

package.json File

"devDependencies": {
        "@sveltejs/adapter-auto": "next",
        "@sveltejs/kit": "next",
        "prettier": "^2.5.1",
        "prettier-plugin-svelte": "^2.5.0",
        "svelte": "^3.44.0",
        "svelte-check": "^2.2.6",
        "typescript": "~4.6.2"
    },

svelte.config.js File

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

/** @type {import('@sveltejs/kit').Config} */
const config = {
    kit: {
        adapter: adapter()
    }
};

export default config;

While the project builds it's throwing errors everywhere. Any help would be appreciated.

jonthornham
  • 2,881
  • 4
  • 19
  • 35

3 Answers3

33

I am using VS Code for the project. The issue is related to opening the project in VS Code, opening a terminal, and running the npm install command.

It appears that npm install must be run in an application like Terminal on a Mac prior to opening the app in VS Code.

jonthornham
  • 2,881
  • 4
  • 19
  • 35
  • 20
    I had the same issue after running `npm install`. Restarting VSCode fixed it. – Diesel Jun 19 '22 at 21:36
  • actually, just closing the project and reopening is enough. No need to restart whole Visual Studio Code. – aknott Mar 08 '23 at 18:33
  • 1
    This is cool and I have upvoted both the answer and the comment by @Diesel! I will share a cooler solution if you're using VSCode and needs a restart. From your terminal, once navigated to the desired location, use `code . -r` to restart the same instance of the VS Code window. – Santhosh John Mar 25 '23 at 19:48
2

Had the same issue, edit package.json:

  • remove line:

    "@svelte:qjs/adapter-auto": "next",

  • then run:
    pnpm i @sveltejs/adapter-auto
    You may replace pnpm with npm or yarn.

  • then in package.json, will get something like:

    "@sveltejs/adapter-auto": "1.0.0-next.55"

That solved the issue.

Eric
  • 22,183
  • 20
  • 145
  • 196
0

My node+npm version was outdated. Make sure you have the latest node version installed.

Bob the Builder
  • 115
  • 3
  • 11