Skip to content

Cannot find module @sveltejs/kit/hooks in dev server #2237

@Karlinator

Description

@Karlinator

Describe the bug

When trying to use the newly merged sequence from @sveltejs/kit/hooks the dev server fails to load the module (and therefore fails to run any hooks).

Adapter-node, however, functions properly and chains the hooks (which also means it's not just a dependency installation issue).

Reproduction

Reproduction repo: https://github.com/Karlinator/reproduction-sveltekit-hooks

As stated, this bug applies (as far as I can tell) only in dev mode. Haven't tested any other adapters than node, but that works.

Logs

Error: Cannot find module '@sveltejs/kit/hooks' from '/home/karl/Git/reproduction-sveltekit-hooks/src'
    at Function.resolveSync [as sync] (/home/karl/Git/reproduction-sveltekit-hooks/node_modules/resolve/lib/sync.js:102:15)
    at resolveFrom$3 (/home/karl/Git/reproduction-sveltekit-hooks/node_modules/vite/dist/node/chunks/dep-98dbe93b.js:4079:29)
    at resolve (/home/karl/Git/reproduction-sveltekit-hooks/node_modules/vite/dist/node/chunks/dep-98dbe93b.js:73902:22)
    at nodeRequire (/home/karl/Git/reproduction-sveltekit-hooks/node_modules/vite/dist/node/chunks/dep-98dbe93b.js:73881:25)
    at ssrImport (/home/karl/Git/reproduction-sveltekit-hooks/node_modules/vite/dist/node/chunks/dep-98dbe93b.js:73823:20)
    at eval (//home/karl/Git/reproduction-sveltekit-hooks/src/hooks.ts:3:37)
    at instantiateModule (/home/karl/Git/reproduction-sveltekit-hooks/node_modules/vite/dist/node/chunks/dep-98dbe93b.js:73866:15)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

System Info

System:
    OS: Linux 5.13 Fedora 34 (Workstation Edition) 34 (Workstation Edition)
    CPU: (8) x64 Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz
    Memory: 656.26 MB / 15.37 GB
    Container: Yes
    Shell: 5.1.0 - /bin/bash
  Binaries:
    Node: 14.17.0 - /usr/bin/node
    npm: 7.20.3 - /usr/local/bin/npm
  Browsers:
    Firefox: 90.0.2
  npmPackages:
    @sveltejs/adapter-node: ^1.0.0-next.39 => 1.0.0-next.42 
    @sveltejs/kit: next => 1.0.0-next.153 
    svelte: ^3.34.0 => 3.42.1

Severity

serious, but I can work around it

Additional Information

Currently working around by either compiling with adapter-node during development or just not using sequence.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingp1-importantSvelteKit cannot be used by a large number of people, basic functionality is missing, etc.vite

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions