vuepress / core

Vue-Powered Static Site Generator
https://vuepress.vuejs.org
MIT License
2.27k stars 927 forks source link

[Bug report] ReferenceError: Cannot access 'defineClientAppSetup' before initialization #176

Closed KnorpelSenf closed 3 years ago

KnorpelSenf commented 3 years ago

Bug report

Description

After updating from beta.11 to beta.12, my project's build process crashes with the following error:

info Initializing VuePress and preparing data...
✔ Compiling with webpack - done
✖ Rendering pages - failed
ReferenceError: Cannot access 'defineClientAppSetup' before initialization
    at Object.F2 (/home/steffen/git/grammy-website/site/docs/.vuepress/dist/.server/app.js:5384:31)
    at Object.6025 (/home/steffen/git/grammy-website/site/docs/.vuepress/dist/.server/app.js:2641:87)
    at __webpack_require__ (/home/steffen/git/grammy-website/site/docs/.vuepress/dist/.server/app.js:6883:42)
    at Object.9977 (/home/steffen/git/grammy-website/site/docs/.vuepress/dist/.server/app.js:5406:32)
    at __webpack_require__ (/home/steffen/git/grammy-website/site/docs/.vuepress/dist/.server/app.js:6883:42)
    at Object.9904 (/home/steffen/git/grammy-website/site/docs/.vuepress/dist/.server/app.js:17:11)
    at __webpack_require__ (/home/steffen/git/grammy-website/site/docs/.vuepress/dist/.server/app.js:6883:42)
    at /home/steffen/git/grammy-website/site/docs/.vuepress/dist/.server/app.js:7017:25
    at /home/steffen/git/grammy-website/site/docs/.vuepress/dist/.server/app.js:7590:3
    at Object.<anonymous> (/home/steffen/git/grammy-website/site/docs/.vuepress/dist/.server/app.js:7593:12)

Unfortunately, I cannot figure out where exactly the issue comes from—I just know that something in the commit range 1279e81e5d07db251917b6f3cb5de47ae9266aaf..f3fadbc8a730a5985115b8e94f9a634b92354ac3 must have caused it.

The same error can be observed in the JavaScript console of Chrome when running vuepress dev.

Steps to reproduce

I created a branch on my project that you can use to reproduce the error. It only adds a single commit that updates the vuepress dependency.

git clone git@github.com:grammyjs/website.git
cd website/site
git checkout update-deps
npm install
npm run docs:build

The issue persists with the current version, i.e. beta.16.

Expected behavior

The build performs as before.

Environment info

  System:
    OS: Linux 4.19 Debian GNU/Linux 10 (buster) 10 (buster)
    CPU: (4) x64 Intel(R) Core(TM) i5-4200M CPU @ 2.50GHz
    Memory: 878.13 MB / 7.55 GB
    Shell: 5.0.3 - /bin/bash
  Binaries:
    Node: 16.2.0 - ~/.nvm/versions/node/v16.2.0/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.13.0 - ~/.nvm/versions/node/v16.2.0/bin/npm
  Utilities:
    Git: 2.20.1 - /usr/bin/git
  Browsers:
    Chrome: 91.0.4472.77
    Firefox: 78.10.0esr
  npmPackages:
    @vuepress/bundler-vite: Not Found
    @vuepress/bundler-webpack:  2.0.0-beta.12 
    @vuepress/cli:  2.0.0-beta.12 
    @vuepress/client:  2.0.0-beta.10 (2.0.0-beta.12)
    @vuepress/core:  2.0.0-beta.11 (2.0.0-beta.12)
    @vuepress/markdown:  2.0.0-beta.11 (2.0.0-beta.12)
    @vuepress/plugin-active-header-links:  2.0.0-beta.12 
    @vuepress/plugin-back-to-top:  2.0.0-beta.12 
    @vuepress/plugin-container:  2.0.0-beta.12 
    @vuepress/plugin-debug: Not Found
    @vuepress/plugin-docsearch: ^2.0.0-beta.11 => 2.0.0-beta.11 
    @vuepress/plugin-git:  2.0.0-beta.12 
    @vuepress/plugin-google-analytics: Not Found
    @vuepress/plugin-medium-zoom:  2.0.0-beta.12 
    @vuepress/plugin-nprogress:  2.0.0-beta.12 
    @vuepress/plugin-palette:  2.0.0-beta.12 
    @vuepress/plugin-prismjs:  2.0.0-beta.12 
    @vuepress/plugin-pwa: Not Found
    @vuepress/plugin-pwa-popup: Not Found
    @vuepress/plugin-register-components: Not Found
    @vuepress/plugin-search: Not Found
    @vuepress/plugin-shiki: Not Found
    @vuepress/plugin-theme-data:  2.0.0-beta.12 
    @vuepress/plugin-toc: Not Found
    @vuepress/shared:  2.0.0-beta.7 
    @vuepress/theme-default:  2.0.0-beta.12 
    @vuepress/theme-vue: Not Found
    @vuepress/utils:  2.0.0-beta.11 
    vue:  3.0.11 
    vue-loader:  16.2.0 
    vue-router:  4.0.8 
    vuepress: 2.0.0-beta.12 => 2.0.0-beta.12 
    vuepress-vite: Not Found
meteorlxy commented 3 years ago

Please clear the node_modules and lockfile, then re-install it. (Suggest to upgrate to latest version)

You are having duplicate package:

https://github.com/grammyjs/website/blob/c8af6941b0fea836260de3d628a19adaa5df52d9/site/package-lock.json#L819-L820

https://github.com/grammyjs/website/blob/c8af6941b0fea836260de3d628a19adaa5df52d9/site/package-lock.json#L724-L725

PeppeL-G commented 2 years ago

Had the same problem when updating from ^2.0.0-beta.24 to ^2.0.0-beta.26. As @meteorlxy suggested, deleting node_modules and package-lock.json and then running npm install fixes the problem.