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

src/layouts/MainLayout.astro:12:31 - error ts(2307): Cannot find module 'virtual:pwa-assets/head' or its corresponding type declarations. #56

Closed
wanghaisheng opened this issue Dec 7, 2024 · 4 comments

Comments

@wanghaisheng
Copy link

when
import { pwaInfo } from 'virtual:pwa-info';
import { pwaAssetsHead } from 'virtual:pwa-assets/head';

{
  "name": "",
  "type": "module",
  "version": "0.0.1",
  "scripts": {
    "generate-pwa-assets": "pwa-assets-generator",
    "restore-literals": "npm run build-processor && node scripts/dist/restoreProcessLiterals.js",
    "build-processor": "tsc -p tsconfig.scripts.json",
    "dev": "npm run build-processor && node scripts/dist/processAstroFiles.js && astro dev",
    "start": "astro dev",
    "build": "npm run build-processor && node scripts/dist/processAstroFiles.js && astro check && astro build && node process-html.mjs",
    "preview": "astro preview",
    "astro": "astro",
    "process-astro": "npm run build-processor && node scripts/dist/processAstroFiles.js"
  },
  "dependencies": {
    "@astrojs/check": "^0.9.4",
    "@astrojs/sitemap": "^3.2.1",
    "@astrojs/starlight": "^0.29.0",
    "@astrojs/starlight-tailwind": "^2.0.3",
    "@astrojs/tailwind": "^5.1.2",
    "@preline/accordion": "^2.5.0",
    "@preline/collapse": "^2.5.0",
    "@preline/dropdown": "^2.5.0",
    "@preline/overlay": "^2.5.0",
    "@preline/tabs": "^2.5.0",
    "astro": "^4.16.13",
    "astro-compressor": "^0.4.1",
    "astro-imagetools": "^0.9.0",
    "clipboard": "^2.0.11",
    "globby": "^14.0.2",
    "gsap": "^3.12.5",
    "html-minifier-terser": "^7.2.0",
    "image-size": "^1.1.1",
    "lenis": "^1.1.16",
    "preline": "^2.5.1",
    "rimraf": "^6.0.1",
    "sharp": "^0.33.5",
    "sharp-ico": "^0.1.5",
    "swiper": "^11.1.15",
    "tailwindcss": "^3.4.15"
  },
  "devDependencies": {
    "@tailwindcss/forms": "^0.5.9",
    "@vite-pwa/assets-generator": "^0.2.6",
    "@vite-pwa/astro": "^0.4.3",
    "astro-vtbot": "^1.10.7",
    "glob": "^8.1.0",
    "@types/node": "^16.11.7",
    "prettier": "^3.3.3",
    "prettier-plugin-astro": "^0.14.1",
    "prettier-plugin-tailwindcss": "^0.6.8",
    "typescript": "^5.6.3"
  }
}


import { registerSW } from 'virtual:pwa-register'

registerSW({
  immediate: true,
  onRegisteredSW(swScriptUrl) {
    console.log('SW registered: ', swScriptUrl)
  },
  onOfflineReady() {
    console.log('PWA application ready to work offline')
  },
})

when run npm run build ,it will give me module not found error

@wanghaisheng
Copy link
Author

image
issue lies whenever I try to install them ,they not found uner .nodemodules

@wanghaisheng
Copy link
Author

image

@wanghaisheng
Copy link
Author

use pnpm finally save files, but error continue
image

@userquin
Copy link
Member

userquin commented Dec 10, 2024

You should register the corresponding types in your tsconfig file or using env.d.ts (check the examples ( https://github.com/vite-pwa/astro/blob/main/examples/pwa-simple/src/env.d.ts ) : https://vite-pwa-org.netlify.app/guide/faq.html#ide-errors-cannot-find-module-ts2307

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

No branches or pull requests

2 participants