Hello,
I'm making this post for what seems to be a rather simple question, but I've already spent the best part of a day trying to figure this out. I'm simply trying to create a TypeScript project that uses SVG.js (https://svgjs.dev/docs/3.0/). My project code will all run in the browser. My project structure looks something like this (excluding node_modules):
.
├── dist
│ ├── index.js
│ └── index.js.map
├── package.json
├── package-lock.json
├── src
│ ├── index.html
│ └── index.ts
└── tsconfig.json
I've installed SVG.js as described in the official docs:
npm install @svgdotjs/svg.js
And then I try to import it as follows (again, as described in the official docs):
import { SVG } from '@svgdotjs/svg.js'
However I can't get this to work. Either I get errors with typescript like the following:
1. Cannot find module '@svgdotjs/svg.js'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?
or typescript can't seem to find attributes of my imported class.
Even when I manage to get it to compile by tweaking the tsconfig.json, I get errors in the browser like:
Uncaught SyntaxError: export declarations may only appear at top level of a module or
Uncaught TypeError: The specifier “@svgdotjs/svg.js” was a bare specifier, but was not remapped to anything. Relative module specifiers must start with “./”, “../” or “/”. index.js:1:21
So now I'm a bit lost, I was wondering if anyone knows of a right way of doing this. Thank you.