简体   繁体   中英

No known conditions for "./standalone" entry in "@firebase/database-compat" package

When running npm run build on my sveltekit project, i get the following error generated by vite :

7:55:49 PM [vite-plugin-svelte] The following packages did not export their `package.json` file so we could not check the "svelte" field. If you had difficulties importing svelte components from a package, then please contact the author and ask them to export the package.json file.
- firebase-admin
✓ 47 modules transformed.
[commonjs] No known conditions for "./standalone" entry in "@firebase/database-compat" package
> No known conditions for "./standalone" entry in "@firebase/database-compat" package
Error: No known conditions for "./standalone" entry in "@firebase/database-compat" package
    at bail (/home/vincent/repos/sveltekit/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:29712:8)
    at resolve$1 (/home/vincent/repos/sveltekit/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:29768:32)
    at resolveExports (/home/vincent/repos/sveltekit/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:30285:12)
    at resolveDeepImport (/home/vincent/repos/sveltekit/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:30301:26)
    at tryNodeResolve (/home/vincent/repos/sveltekit/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:30043:11)
    at Object.resolveId (/home/vincent/repos/sveltekit/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:29910:28)
    at /home/vincent/repos/sveltekit/node_modules/rollup/dist/shared/rollup.js:22697:251

I checked in the node_modules and the package @firebase/database-compat actually exports his package.json. I'm really stuck here.

Here is my package.json :

{
  "private": true,
  "type": "module",
  "scripts": {
    "dev": "svelte-kit dev",
    "build": "svelte-kit build --verbose",
    "preview": "svelte-kit preview"
  },
  "devDependencies": {
    "@sveltejs/adapter-vercel": "next",
    "@sveltejs/kit": "next",
    "@tsconfig/svelte": "^2.0.1",
    "@types/body-parser": "^1.19.1",
    "@types/cookie": "^0.4.1",
    "sass": "^1.39.2",
    "svelte": "^3.38.3",
    "typescript": "^4.4.3"
  },
  "dependencies": {
    "body-parser": "^1.19.0",
    "cookie": "^0.4.1",
    "firebase": "^9.4.1",
    "firebase-admin": "^10.0.0",
    "prettier": "^2.3.2",
    "prettier-plugin-svelte": "^2.3.1",
    "svelte-preprocess": "^4.9.4"
  },
  "prettier": {
    "arrowParens": "always",
    "singleQuote": true,
    "tabWidth": 2,
    "trailingComma": "none"
  }
}

did you find an answer ? i'm having the same problem

I had to change the import from CJS style to ESM style.

From: const { Pkg } = require('package/sub')

To: import { Pkg } from 'package/sub'

Perhaps Vite just isn't able to resolve the way this package is exported and imported in this case?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM