Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem that cannot be imported after installation #25

Closed
Edge-coordinates opened this issue Aug 31, 2023 · 7 comments · Fixed by #26
Closed

Problem that cannot be imported after installation #25

Edge-coordinates opened this issue Aug 31, 2023 · 7 comments · Fixed by #26
Labels
question Further information is requested

Comments

@Edge-coordinates
Copy link

I installed this module using pnpm, and I've also installed the Svelte for VS Code plugin. However, following the official instructions to import had no effect (I encountered the error shown in the screenshot.). After trying to add the following line to the package's package.json:

"main": "./dist/index.js",

I found that doing this made it work properly.

image

@janosh
Copy link
Owner

janosh commented Aug 31, 2023

Can you post your package.json? What did you set for key "type"?

@janosh janosh added the question Further information is requested label Aug 31, 2023
@Edge-coordinates
Copy link
Author

{
  "name": "vite-electron-builder",
  "description": "Secure boilerplate for Electron app based on Vite",
  "version": "1.0.2",
  "private": true,
  "author": {
    "email": "kozackunisoft@gmail.com",
    "name": "Alex Kozack",
    "url": "https://kozack.me"
  },
  "type": "module",
  "main": "packages/main/dist/index.cjs",
  "scripts": {
    "build": "npm run build:main && npm run build:preload && npm run build:renderer",
    "build:main": "cd ./packages/main && vite build",
    "build:preload": "cd ./packages/preload && vite build",
    "build:renderer": "vite build",
    "compile": "cross-env MODE=production npm run build && electron-builder build --config .electron-builder.config.cjs --dir --config.asar=false",
    "test": "npm run test:main && npm run test:preload && npm run test:renderer && npm run test:e2e",
    "test:e2e": "npm run build && vitest run",
    "test:main": "vitest run -r packages/main --passWithNoTests",
    "test:preload": "vitest run -r packages/preload --passWithNoTests",
    "test:renderer": "vitest run --passWithNoTests --config src/vitest.config.cjs",
    "watch": "node scripts/watch.mjs",
    "lint": "eslint . --ext js,mjs,cjs,ts,mts,cts,svelte",
    "typecheck:main": "tsc --noEmit -p packages/main/tsconfig.json",
    "typecheck:preload": "tsc --noEmit -p packages/preload/tsconfig.json",
    "typecheck:renderer": "tsc --noEmit",
    "typecheck": "npm run typecheck:main && npm run typecheck:preload && npm run typecheck:renderer",
    "postinstall": "cross-env ELECTRON_RUN_AS_NODE=1 electron scripts/update-electron-vendors.mjs",
    "format": "npx prettier --write \"**/*.{js,mjs,cjs,ts,mts,cts,svelte,json}\""
  },
  "devDependencies": {
    "@playwright/test": "^1.31.1",
    "@ptkdev/sveltekit-electron-adapter": "^0.3.0",
    "@sveltejs/adapter-static": "^2.0.1",
    "@sveltejs/kit": "^1.5.0",
    "@types/node": "18.14.1",
    "@typescript-eslint/eslint-plugin": "5.53.0",
    "@typescript-eslint/parser": "^5.45.0",
    "autoprefixer": "^10.4.15",
    "cross-env": "7.0.3",
    "daisyui": "^3.5.1",
    "electron": "23.1.1",
    "electron-builder": "23.6.0",
    "eslint": "8.35.0",
    "eslint-config-prettier": "^8.5.0",
    "eslint-plugin-svelte3": "^4.0.0",
    "happy-dom": "8.9.0",
    "nano-staged": "0.8.0",
    "playwright": "1.31.1",
    "postcss": "^8.4.28",
    "prettier": "^2.8.0",
    "prettier-plugin-svelte": "^2.8.1",
    "simple-git-hooks": "2.8.1",
    "svelte": "^3.54.0",
    "svelte-bricks": "^0.2.0",
    "svelte-check": "^3.0.1",
    "tailwindcss": "^3.3.3",
    "tslib": "^2.4.1",
    "typescript": "4.9.5",
    "unplugin-auto-expose": "0.0.4",
    "vite": "4.1.4",
    "vitest": "0.29.1"
  },
  "dependencies": {
    "electron-updater": "5.3.0",
    "viewerjs": "^1.11.5"
  }
}

this is my package.json, "type": "module",

@Edge-coordinates
Copy link
Author

image

I added a line to your package.json "main": "./dist/index.js", then , it work

@janosh
Copy link
Owner

janosh commented Sep 2, 2023

Not a JS packaging expert but maybe the need for "main": "./dist/index.js" comes from an outdated node or electron version? Never used electron but looks like its on version 26.x. Have you also tried updating without adding "main": "./dist/index.js"?

@timmyrosen
Copy link

timmyrosen commented Sep 22, 2023

@janosh I have the same issue, setting the "main" key did not work. I'm not using electron, just started up a basic Sveltekit app and installed this package.

Note: I am using Svelte with Typescript

@janosh
Copy link
Owner

janosh commented Sep 22, 2023

@timmyrosen Just to confirm, you only had type resolution issues, no runtime import error, correct?

The type resolution should be fixed in v0.2.1. Can you give it a try?

@timmyrosen
Copy link

@janosh Yep, works fine now, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants