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

[vite] Internal server error: Missing "./dist/style.css" export in "vue3-markdown" package - Plugin: vite:css #6480

Closed
7 tasks done
carmel opened this issue Jan 12, 2022 · 2 comments

Comments

@carmel
Copy link

carmel commented Jan 12, 2022

Describe the bug

My project uses a dependency library on npm, and I get this error when I import the css from the dependency library.

!!! However, the same code works fine with vue-cli. vue-cli demo

Reproduction

https://stackblitz.com/edit/vite-yrtqob?file=vite.config.js

System Info

  System:    
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 14.16.1 - ~/ENV/node/bin/node
    Yarn: 1.22.10 - ~/ENV/node/global/bin/yarn
    npm: 6.14.12 - ~/ENV/node/bin/npm
  npmPackages:
    @vitejs/plugin-vue: ^2.0.0 => 2.0.1 
    vite: ^2.7.2 => 2.7.10

Used Package Manager

yarn

Logs

node_modules/vite/dist/node/chunks/dep-76613303.js:29941:7: error: [plugin: vite:dep-scan] Missing "./dist/style.css" export in "vue3-markdown" package
    29941 │   throw new Error(
          ╵         ^
    at bail (/home/projects/vite-yrtqob/node_modules/vite/dist/node/chunks/dep-76613303.js:29941:8)
    at resolve (/home/projects/vite-yrtqob/node_modules/vite/dist/node/chunks/dep-76613303.js:30018:10)
    at resolveExports (/home/projects/vite-yrtqob/node_modules/vite/dist/node/chunks/dep-76613303.js:30641:12)
    at resolveDeepImport (/home/projects/vite-yrtqob/node_modules/vite/dist/node/chunks/dep-76613303.js:30657:26)
    at tryNodeResolve (/home/projects/vite-yrtqob/node_modules/vite/dist/node/chunks/dep-76613303.js:30440:20)
    at Context.resolveId (/home/projects/vite-yrtqob/node_modules/vite/dist/node/chunks/dep-76613303.js:30257:28)
    at Object.resolveId (/home/projects/vite-yrtqob/node_modules/vite/dist/node/chunks/dep-76613303.js:36922:55)
    at async resolve (/home/projects/vite-yrtqob/node_modules/vite/dist/node/chunks/dep-76613303.js:37125:26)
    at async eval (/home/projects/vite-yrtqob/node_modules/vite/dist/node/chunks/dep-76613303.js:37263:34)
    at async callback (/home/projects/vite-yrtqob/node_modules/esbuild/lib/main.js:832:28)

   node_modules/vite/dist/node/chunks/dep-76613303.js:37253:18: note: This error came from the "onResolve" callback registered here
    37253 │             build.onResolve({
          ╵                   ~~~~~~~~~
    at setup (/home/projects/vite-yrtqob/node_modules/vite/dist/node/chunks/dep-76613303.js:37253:19)
    at handlePlugins (/home/projects/vite-yrtqob/node_modules/esbuild/lib/main.js:756:23)
    at Object.buildOrServe (/home/projects/vite-yrtqob/node_modules/esbuild/lib/main.js:1044:7)
    at eval (/home/projects/vite-yrtqob/node_modules/esbuild/lib/main.js:1895:17)
    at new Promise (<anonymous>)
    at Object.build (/home/projects/vite-yrtqob/node_modules/esbuild/lib/main.js:1894:14)
    at Object.build (/home/projects/vite-yrtqob/node_modules/esbuild/lib/main.js:1749:51)
    at eval (/home/projects/vite-yrtqob/node_modules/vite/dist/node/chunks/dep-76613303.js:37083:54)
    at Array.map (<anonymous>)

   local-script:/home/projects/vite-yrtqob/App.vue:4:7: note: The plugin "vite:dep-scan" was triggered by this import
        4 │ import 'vue3-markdown/dist/style.css';~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error when starting dev server:
Error: Build failed with 1 error:
node_modules/vite/dist/node/chunks/dep-76613303.js:29941:7: error: [plugin: vite:dep-scan] Missing "./dist/style.css" export in "vue3-markdown" package
    at failureErrorWithLog (/home/projects/vite-yrtqob/node_modules/esbuild/lib/main.js:1493:15)
    at eval (/home/projects/vite-yrtqob/node_modules/esbuild/lib/main.js:1151:28)
    at runOnEndCallbacks (/home/projects/vite-yrtqob/node_modules/esbuild/lib/main.js:941:63)
    at buildResponseToResult (/home/projects/vite-yrtqob/node_modules/esbuild/lib/main.js:1149:7)
    at eval (/home/projects/vite-yrtqob/node_modules/esbuild/lib/main.js:1258:14)
    at eval (/home/projects/vite-yrtqob/node_modules/esbuild/lib/main.js:629:9)
    at handleIncomingPacket (/home/projects/vite-yrtqob/node_modules/esbuild/lib/main.js:726:9)
    at Socket.readFromStdout (/home/projects/vite-yrtqob/node_modules/esbuild/lib/main.js:596:7)
    at Socket.EventEmitter.emit (https://vite-yrtqob.w.staticblitz.com/blitz.528f704493b63b14b6f9ee36935eead8382e8395.js:6:126633)
    at addChunk (https://vite-yrtqob.w.staticblitz.com/blitz.528f704493b63b14b6f9ee36935eead8382e8395.js:6:516009)

Validations

@carmel
Copy link
Author

carmel commented Jan 13, 2022

Any help?

@carmel
Copy link
Author

carmel commented Jan 13, 2022

wow, it was caused by vite's strict adherence to the exports field in the package.json, which css file does not exported. Of course, this is the package.json in vue3-markdown, but it has fixed now. This issue can now be closed.

"exports": {
    ".": {
      "import": "./dist/vue3-markdown.es.js",
      "require": "./dist/vue3-markdown.umd.js"
    },
    "./dist/style.css": "./dist/style.css"
  }

@Niputi Niputi closed this as completed Jan 13, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants