0

I am encountering an issue while trying to access a component from a Git subtree in my Svelte project. Here’s a simplified view of my project structure:

root
- .subtree
  - imports
    - ui
      - Searchbar.svelte
- imports
  - ui
    - App.svelte

I am attempting to import Searchbar.svelte from the .subtree directory into App.svelte. However, I keep getting an error: Error: Cannot find module /.subtree/imports/ui/ThreeColumnLayout.svelte.

Here’s the snippet from App.svelte where I attempt to import and use Searchbar.svelte:

<script>
  import Searchbar from "/.subtree/imports/ui/ThreeColumnLayout.svelte";
  // Assuming these are required props for Searchbar
  export let placeholder = "Search Here...";
</script>

<div class="relative">
  <label for="search" class="absolute flex items-center left-2 top-2 justify-center">
    <!-- Placeholder SVG code -->
    <svg width="24" height="24" viewBox="0 0 24 24">
      <path d="m21 21-5.2-5.2m0 0A7.5 7.5 0 1 0 5.2 5.2a7.5 7.5 0 0 0 10.6 10.6" />
    </svg>
  </label>

  <!-- Use the Searchbar component -->
  <Searchbar {placeholder} />
</div>

I have tried different file paths such as ../../.subtree/imports/ui/ThreeColumnLayout.svelte and /.subtree/imports/ui/ThreeColumnLayout.svelte, but the error persists.

3
  • What bundler/build tools are you using? Commented Jul 3, 2024 at 21:26
  • I am using Meteor as my build tool and framework. Both the repositories (subtree and parent) were created using meteor create --svelte simple-todos-svelte --prototype. @brunnerh Commented Jul 4, 2024 at 8:23
  • Meteor does not natively recognize subdirectories outside of its usual imports, maybe it is the issue. You can link it like this: ln -s .subtree/imports/ui imports/subtree-ui Commented Jul 4, 2024 at 12:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.