howesteve / elegua

Elegua - a small, reactive PWA router for Svelte
https://elegua.netlify.app/
Apache License 2.0
76 stars 4 forks source link

Error importing: Cannot find module 'elegua' or its corresponding type declarations #2

Closed conradolandia closed 1 year ago

conradolandia commented 1 year ago

If I install the package either from npm or git, I can't import it. Always gives the error Error importing: Cannot find module 'elegua' or its corresponding type declarations.

howesteve commented 1 year ago

Did you install it in your project, i.e. pnpm install elegua? What version of Elegua are you using?

conradolandia commented 1 year ago

I installed it using the options you presented in the README: npm i -D elegua. Also tried with pnpm, neither worked. I also tried npm i -D https://github.com/howesteve/elegua, also widn't work. I didn't specify a version, so the last available one I guess.

howesteve commented 1 year ago

It's working here. Do you mean the demo app? I forced elegua as a self dependency. Try with latest version and see if it's better.

conradolandia commented 1 year ago

No, I mean installing it on a custom Svelte project. I will try again and if I get the error I will paste it here.

slavnycoder commented 1 year ago

Same image image

howesteve commented 1 year ago

It's working here. Can anyone provide me a repository where I could replicate the situation? Or just try the steps below?

gargamel::~/ttt $ git clone https://github.com/howesteve/elegua
Cloning into 'elegua'...
remote: Enumerating objects: 219, done.
remote: Counting objects: 100% (219/219), done.
remote: Compressing objects: 100% (128/128), done.
remote: Total 219 (delta 103), reused 181 (delta 65), pack-reused 0
Receiving objects: 100% (219/219), 80.28 KiB | 6.17 MiB/s, done.
Resolving deltas: 100% (103/103), done.
gargamel::~/ttt $ cd elegua
gargamel::~/ttt/elegua ‹master› $ pnpm install
Lockfile is up to date, resolution step is skipped
Packages: +201
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Packages are hard linked from the content-addressable store to the virtual store.
  Content-addressable store is at: /home/howe/.local/share/pnpm/store/v3
  Virtual store is at:             node_modules/.pnpm
Progress: resolved 201, reused 201, downloaded 0, added 201, done

dependencies:
+ svelte 3.59.1

devDependencies:
+ @sveltejs/adapter-auto 2.1.0
+ @sveltejs/kit 1.20.4
+ @sveltejs/package 2.0.2
+ @sveltejs/vite-plugin-svelte 2.4.1
+ @typescript-eslint/eslint-plugin 5.59.11
+ @typescript-eslint/parser 5.59.11
+ elegua 1.0.7
+ eslint 8.43.0
+ eslint-config-prettier 8.8.0
+ eslint-plugin-svelte3 4.0.0
+ prettier 2.8.8
+ prettier-plugin-svelte 2.10.1
+ svelte-check 3.4.3
+ tslib 2.5.3
+ typescript 5.1.3
+ vite 4.3.9

Done in 1.4s
gargamel::~/ttt/elegua ‹master› $ pnpm run dev

> elegua@1.0.8 dev /home/howe/ttt/elegua
> echo Starting demo application... && vite dev

Starting demo application...
Forced re-optimization of dependencies
Port 5173 is in use, trying another one...

  VITE v4.3.9  ready in 719 ms

  ➜  Local:   http://localhost:5174/
  ➜  Network: use --host to expose
  ➜  press h to show help
conradolandia commented 1 year ago

Your demo app works. Sorry for the trouble, man. I got my own working. I had to copy the file Elegua.svelte from your demo app to my project's lib/ folder, and it finally worked using import Router, { path, url, hash } from './lib/Elegua.svelte';, in a similar way as you load it on your demo app. However, your README file says to use import Route, { params, matches } from 'elegua';, I guess to load it as a module from node_modules? which doesn't work. VSCode complains that the module can´t be found. There are no errors on the console, but the Router is not rendered importing it this way. I've tried installing Elegua with npm and pnpm, multiple times, closely following the README.

Just to be clear: The only way I made it work was manually copying Elegua.svelte to my project and importing it from there. It works fine this way. It does not work when I try to import it as a node module, i.e: import Route from 'elegua';. It does not matter if I use pnpm or npm.

howesteve commented 1 year ago

Closing since v 2.0 is released and can't reproduce issue.