svgdotjs / svgdom

Straightforward DOM implementation to make SVG.js run headless on Node.js
MIT License
269 stars 53 forks source link

NodeJS installation instructions #102

Open maxwowpow opened 1 year ago

maxwowpow commented 1 year ago
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'XXX\node_modules\@svgdotjs\svg.js\' imported from app.js
    at new NodeError (node:internal/errors:399:5)
    at legacyMainResolve (node:internal/modules/esm/resolve:202:9)
ammoradi commented 4 months ago

Any news on this?

Fuzzyma commented 2 months ago

Why are you pulling from github? Install via npm and the dist folder is right there. You obvisouly need svgdom for this to run:

import { SVG, registerWindow } from "@svgdotjs/svg.js";
import { createSVGWindow } from "svgdom";

const window = createSVGWindow();
registerWindow(window, window.document);

const svg = SVG().addTo(window.document.documentElement);

svg.rect(100, 100);

console.log(svg.svg());