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: Unexpected string Plugin: vite:css #2793

Closed
6 tasks done
mariusa opened this issue Mar 30, 2021 · 4 comments · Fixed by #7934
Closed
6 tasks done

[vite] Internal server error: Unexpected string Plugin: vite:css #2793

mariusa opened this issue Mar 30, 2021 · 4 comments · Fixed by #7934
Labels
contribution welcome feat: css p1-chore Doesn't change code behavior (priority)

Comments

@mariusa
Copy link

mariusa commented Mar 30, 2021

Describe the bug

I get the same error by simply closing any of these 2 projects, run npm install and npm run dev:
https://github.com/martinussuherman/vue-template
https://github.com/matt-auckland/vite-vue2-starter

[vite] Internal server error: Unexpected string
  Plugin: vite:css
  File: /home/marius/work/vue-template/src/App.vue?vue&type=style&index=0&lang.scss
      at wrapSafe (internal/modules/cjs/loader.js:979:16)
      at Module._compile (internal/modules/cjs/loader.js:1027:27)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
      at Module.load (internal/modules/cjs/loader.js:928:32)
      at Function.Module._load (internal/modules/cjs/loader.js:769:14)
      at Module.require (internal/modules/cjs/loader.js:952:19)
      at require (internal/modules/cjs/helpers.js:88:18)
      at importFresh (/home/marius/work/vue-template/node_modules/vite/dist/node/chunks/dep-6e02b235.js:5931:47)
      at loadJs (/home/marius/work/vue-template/node_modules/vite/dist/node/chunks/dep-6e02b235.js:15294:18)
      at Explorer.loadFileContent (/home/marius/work/vue-template/node_modules/vite/dist/node/chunks/dep-6e02b235.js:15777:32)
      at Explorer.createCosmiconfigResult (/home/marius/work/vue-template/node_modules/vite/dist/node/chunks/dep-6e02b235.js:15782:36)
      at Explorer.loadSearchPlace (/home/marius/work/vue-template/node_modules/vite/dist/node/chunks/dep-6e02b235.js:15763:31)
      at async Explorer.searchDirectory (/home/marius/work/vue-template/node_modules/vite/dist/node/chunks/dep-6e02b235.js:15748:27)
      at async run (/home/marius/work/vue-template/node_modules/vite/dist/node/chunks/dep-6e02b235.js:15728:22)
      at async cacheWrapper (/home/marius/work/vue-template/node_modules/vite/dist/node/chunks/dep-6e02b235.js:15580:18)
      at async cacheWrapper (/home/marius/work/vue-template/node_modules/vite/dist/node/chunks/dep-6e02b235.js:15580:18)

Once I managed to get the error when removing depency @vue/cli-service (#2757). Adding it to those 2 projects doesn't get rid of the error though.

Reproduction

https://github.com/martinussuherman/vue-template

There must be something wrong with my setup, since these 2 projects work for others.
But vite doesn't make it clearer what that is.

System Info

vite 2.1.4

Output of npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers:

  System:
    OS: Linux 5.11 Fedora 34 (Workstation Edition Prerelease) 34 (Workstation Edition Prerelease)
    CPU: (8) x64 AMD Ryzen 7 4700U with Radeon Graphics
    Memory: 6.86 GB / 15.07 GB
    Container: Yes
    Shell: 5.1.0 - /bin/bash
  Binaries:
    Node: 14.15.4 - /usr/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 6.14.10 - /usr/bin/npm
  Browsers:
    Chrome: 89.0.4389.90
    Firefox: 86.0
  npmPackages:
    vite: ^2.0.2 => 2.1.4 

Used package manager:
npm

I also have these installed

npm i -g @babel/core  @babel/eslint-parser cross-env eslint eslint-plugin-vue eslint-plugin-html foreman jsonpp nodemon serve @vue/cli webpack webpack-cli

Logs

[vite] Internal server error: Unexpected string
  Plugin: vite:css
  File: /home/marius/work/vue-template/src/App.vue?vue&type=style&index=0&lang.scss
      at wrapSafe (internal/modules/cjs/loader.js:979:16)
      at Module._compile (internal/modules/cjs/loader.js:1027:27)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
      at Module.load (internal/modules/cjs/loader.js:928:32)
      at Function.Module._load (internal/modules/cjs/loader.js:769:14)
      at Module.require (internal/modules/cjs/loader.js:952:19)
      at require (internal/modules/cjs/helpers.js:88:18)
      at importFresh (/home/marius/work/vue-template/node_modules/vite/dist/node/chunks/dep-6e02b235.js:5931:47)
      at loadJs (/home/marius/work/vue-template/node_modules/vite/dist/node/chunks/dep-6e02b235.js:15294:18)
      at Explorer.loadFileContent (/home/marius/work/vue-template/node_modules/vite/dist/node/chunks/dep-6e02b235.js:15777:32)
      at Explorer.createCosmiconfigResult (/home/marius/work/vue-template/node_modules/vite/dist/node/chunks/dep-6e02b235.js:15782:36)
      at Explorer.loadSearchPlace (/home/marius/work/vue-template/node_modules/vite/dist/node/chunks/dep-6e02b235.js:15763:31)
      at async Explorer.searchDirectory (/home/marius/work/vue-template/node_modules/vite/dist/node/chunks/dep-6e02b235.js:15748:27)
      at async run (/home/marius/work/vue-template/node_modules/vite/dist/node/chunks/dep-6e02b235.js:15728:22)
      at async cacheWrapper (/home/marius/work/vue-template/node_modules/vite/dist/node/chunks/dep-6e02b235.js:15580:18)
      at async cacheWrapper (/home/marius/work/vue-template/node_modules/vite/dist/node/chunks/dep-6e02b235.js:15580:18)
  vite:time 61ms  /src/App.vue?vue&type=style&index=0&lang.scss +44ms
  vite:load 1ms   [fs] /src/views/Home.vue +48ms
  vite:resolve 0ms   vue-property-decorator -> /home/marius/work/vue-template/node_modules/.vite/vue-property-decorator.js?v=8019293c +164ms
  vite:resolve 0ms   /node_modules/.vite/vue-property-decorator.js?v=8019293c -> /home/marius/work/vue-template/node_modules/.vite/vue-property-decorator.js?v=8019293c +0ms
  vite:resolve 0ms   /src/views/Home.vue?vue&type=template&lang.js -> /home/marius/work/vue-template/src/views/Home.vue?vue&type=template&lang.js +1ms
  vite:hmr [self-accepts] src/views/Home.vue +202ms
  vite:transform 19ms  /src/views/Home.vue +66ms
  vite:time 21ms  /src/views/Home.vue +22ms
  vite:time 7ms   /favicon.ico +71ms

Before submitting the issue, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Provide a description in this issue that describes the bug.
  • Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
  • Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
    no answer in Q&A, Discord says invite is invalid.
@sodatea
Copy link
Member

sodatea commented Apr 12, 2021

So the error trace shows that it's raised by comiconfig, which is in turn depended by postcss-load-config.

Please check your PostCSS config file in the upper-level directories of your cloned project.

@sodatea
Copy link
Member

sodatea commented Apr 12, 2021

On the other side, though the vite:css error message helped me narrow down the problem, I think there's still room for improvement by catching config loading errors.

Contributions are welcome.

@mariusa
Copy link
Author

mariusa commented Apr 14, 2021

Thank you! There was indeed a PostCSS config file in the upper-level directories -- removing that solved the error.
Per your last comment, I'll leave this issue open.

@github-actions
Copy link

github-actions bot commented Mar 6, 2022

Hello @mariusa. We like your proposal/feedback and would appreciate a contribution via a Pull Request by you or another community member. We thank you in advance for your contribution and are looking forward to reviewing it!

@github-actions github-actions bot locked and limited conversation to collaborators May 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
contribution welcome feat: css p1-chore Doesn't change code behavior (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants