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: Cannot read property 'length' of undefined #1600

Closed
3 tasks
cllemon opened this issue Jan 20, 2021 · 0 comments
Closed
3 tasks

Comments

@cllemon
Copy link

cllemon commented Jan 20, 2021

⚠️ IMPORTANT ⚠️ Please check the following list before proceeding. If you ignore this issue template, your issue will be directly closed.

  • Read the docs.
  • Use Vite >=2.0. (1.x is no longer supported)
  • If the issue is related to 1.x -> 2.0 upgrade, read the Migration Guide first.

Describe the bug

In the vue project created with vite (jsx added):

npm run dev

Output:

2:36:51 PM [vite] Internal server error: Cannot read property 'length' of undefined
      at posToNumber (/Users/kite/vite/packages/vite/src/node/utils.ts:204:23)
      at Object.generateCodeFrame (/Users/kite/vite/packages/vite/src/node/utils.ts:237:11)
      at formatError (/Users/kite/vite/packages/vite/src/node/server/pluginContainer.ts:311:34)
      at TransformContext.error (/Users/kite/vite/packages/vite/src/node/server/pluginContainer.ts:276:13)
      at Object.transform (/Users/kite/vite/packages/vite/src/node/server/pluginContainer.ts:521:15)

After investigation, the css code in the .less file references an undefined variable.
However, vite’s internal error information covers the valuable error information needed.

Expected output:

2:35:54 PM [vite] Internal server error: variable @mini-heights is undefined
  Plugin: vite:css
  File: /Users/kite/my-vue-app/src/styles/index.less
      at less (/Users/kite/vite/packages/vite/src/node/plugins/css.ts:533:42)
      at compileCSS (/Users/kite/vite/packages/vite/src/node/plugins/css.ts:329:36)
      at TransformContext.transform (/Users/kite/vite/packages/vite/src/node/plugins/css.ts:88:42)
      at Object.transform (/Users/kite/vite/packages/vite/src/node/server/pluginContainer.ts:517:20)
      at Object.transformRequest (/Users/kite/vite/packages/vite/src/node/server/transformRequest.ts:123:27)
      at /Users/kite/vite/packages/vite/src/node/server/middlewares/transform.ts:119:24

Reproduction

https://github.com/cllemon/my-vue-app

System Info

  • vite version: v2.0.0-beta.34
  • Operating System: MacOS Catalina v10.15.5
  • Node version: v12.13.0
  • Package manager (npm/yarn/pnpm) and version: npm v6.14.4

Logs (Optional if provided reproduction)

2:36:51 PM [vite] Internal server error: Cannot read property 'length' of undefined
      at posToNumber (/Users/kite/vite/packages/vite/src/node/utils.ts:204:23)
      at Object.generateCodeFrame (/Users/kite/vite/packages/vite/src/node/utils.ts:237:11)
      at formatError (/Users/kite/vite/packages/vite/src/node/server/pluginContainer.ts:311:34)
      at TransformContext.error (/Users/kite/vite/packages/vite/src/node/server/pluginContainer.ts:276:13)
      at Object.transform (/Users/kite/vite/packages/vite/src/node/server/pluginContainer.ts:521:15)
@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
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

1 participant