Error creating NPM package with SvelteKit

67 Views Asked by At

Let's go. I created the package and am trying to test it locally. I ran the npm run package, and installed it locally with npm install <path>. When installing the package I have the following problems: When inserting the forward slash (/) to access a submodule, instead of displaying the available modules, it displays a list of the entire directory where I am working on the package, instead of only displaying the path to the submodule. In VSCode, if I add svelte-base-app/dist/auth it doesn't display any error but the code doesn't work. When changing the import to svelte-base-app/auth, VSCode displays an error (Cannot find module svelte-base-app/auth), but the code works normally. My packge.json:

{
    "name": "svelte-base-app",
    "version": "0.0.1",
    "scripts": {
        "dev": "vite dev",
        "build": "vite build && npm run package",
        "preview": "vite preview",
        "package": "svelte-kit sync && svelte-package && publint",
        "prepublishOnly": "npm run package",
        "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
        "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
    },
    "exports": {
        ".": {
            "types": "./dist/index.d.ts",
            "svelte": "./dist/index.js"
        },
        "./auth": {
            "types": "./dist/auth/index.d.ts",
            "svelte": "./dist/auth/index.js"
        }
    },
    "files": [
        "dist",
        "!dist/**/*.test.*",
        "!dist/**/*.spec.*"
    ],
    "peerDependencies": {
        "svelte": "^4.0.0",
        "@sveltejs/kit": "^1.20.4"
    },
    "devDependencies": {
        "@sveltejs/adapter-auto": "^2.0.0",
        "@sveltejs/kit": "^1.20.4",
        "@sveltejs/package": "^2.0.0",
        "less": "^4.2.0",
        "publint": "^0.1.9",
        "svelte": "^4.0.5",
        "svelte-check": "^3.4.3",
        "tslib": "^2.4.1",
        "typescript": "^5.0.0",
        "vite": "^4.4.2"
    },
    "svelte": "./dist/index.js",
    "types": "./dist/index.d.ts",
    "type": "module"
}

enter image description here

0

There are 0 best solutions below