question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when starting caused by plugins.

See original GitHub issue

I can not start with npm run vite, the console output is like:

> node ./bin/vite

running: vite --config X:\A\src\node_modules\_vue-cli-plugin-vite@1.0.0-rc.3@vue-cli-plugin-vite\config\index.ts
error when starting dev server:
TypeError: Cannot read property 'apply' of undefined
    at X:\A\src\node_modules\_vite@2.0.5@vite\dist\node\chunks\dep-e0f09032.js:48165:19
    at Array.filter (<anonymous>)
    at resolveConfig (X:\A\src\node_modules\_vite@2.0.5@vite\dist\node\chunks\dep-e0f09032.js:48164:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async createServer (X:\A\src\node_modules\_vite@2.0.5@vite\dist\node\chunks\dep-e0f09032.js:68144:20)
    at async CAC.<anonymous> (X:\A\src\node_modules\_vite@2.0.5@vite\dist\node\cli.js:14027:24)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mjapp@2.5.0 vite: `node ./bin/vite`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mjapp@2.5.0 vite script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     D:\Programs\nodejs\global\cache\_logs\2021-04-19T17_08_49_381Z-debug.log

By looking at the ts codes, it is caused by these lines in node_modules\_vue-cli-plugin-vite@1.0.0-rc.3@vue-cli-plugin-vite\config\index.ts line 45-48:

export default defineConfig({
  plugins: [
    envCompatible(),
    // auto infer pages
    htmlTemplate({ pages: vueConfig.pages || {} }),
    vueCli(),
    createVuePlugin(viteOptions.vitePluginVue2Options),
    useMPA
      ? mpa()
      : undefined,
    ...extraPlugins,
  ],
  optimizeDeps: viteOptions.optimizeDeps,
})

When this is not mpa, it will add an undefined to plugins for user config. Thus, the flat().filter() won’t deal it properly because it can not access plugins for undefined.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
boxsnakecommented, Apr 20, 2021

maybe in bin/vite use npx vite instead of vite directly? try it

I changed the vite to npx vite in cross-spawn, and it works. Thanks.

0reactions
IndexXuancommented, Apr 20, 2021

maybe in bin/vite use npx vite instead of vite directly? try it

Read more comments on GitHub >

github_iconTop Results From Across the Web

WordPress Plugin Troubleshooting: What To Do When Your ...
Go to the Plugins page. · Click the Deactivate link associated with the plugin causing the issue. · Check your site. · If...
Read more >
Confluence plugins have version errors on start up ... - Jira
Often, on startup or on Add-on update Confluence has errors with Add-Ons that have versions that clash with each other. This often causes...
Read more >
How to Fix the "There Has Been a Critical Error on Your ...
Luckily, fixing this critical error is usually just a matter of adding a small PHP function or deleting a problem plugin. Here we'll...
Read more >
Solve Problems With Plugins – WordPress.com Support
Check if the issue still exists. If the error is no longer present, the plugin(s) you deactivated was causing the conflict. Determine which...
Read more >
Troubleshooting 101: Plugin Causing Fatal Error
Troubleshooting 101: Plugin Causing Fatal Error · Pinpoint the Error · Log in to your site via FTP · Rename the conflicting plugin...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found