vuejs / vuepress

πŸ“ Minimalistic Vue-powered static site generator
https://vuepress.vuejs.org
MIT License
22.44k stars 4.78k forks source link

fresh new 1.x project fails to build (but dev works OK) #3065

Open jorismak opened 2 years ago

jorismak commented 2 years ago

Bug report

Steps to reproduce

mkdir my-new-project
cd my-new-project
npx create-vuepress-site
npm run dev
npm run build

What is expected?

Successful build when a project is just scaffolded.

What is actually happening?

$ npm run build

> vuepress-test@0.0.1 build
> vuepress build src

wait Extracting site metadata...
tip Apply theme @vuepress/theme-default ...
warning An error was encountered in plugin "@vuepress/plugin-back-to-top"
warning An error was encountered in plugin "@vuepress/plugin-medium-zoom"
tip Apply plugin container (i.e. "vuepress-plugin-container") ...
tip Apply plugin @vuepress/register-components (i.e. "@vuepress/plugin-register-components") ...
tip Apply plugin @vuepress/active-header-links (i.e. "@vuepress/plugin-active-header-links") ...
tip Apply plugin @vuepress/search (i.e. "@vuepress/plugin-search") ...
tip Apply plugin @vuepress/nprogress (i.e. "@vuepress/plugin-nprogress") ...

βœ– Client
  Compiled with some errors in 7.44s

βœ” Server
  Compiled successfully in 5.74s

(undefined) ./node_modules/@vuepress/core/.temp/style.styl
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
TypeError: Cannot read property 'prototype' of undefined
    at Object.<anonymous> (/home/joris/vhosts/vuepress-test/docs/node_modules/css-loader/dist/cjs.js??ref--13-oneOf-1-1!/home/joris/vhosts/vuepress-test/docs/node_modules/postcss-loader/src/index.js??ref--13-oneOf-1-2!/home/joris/vhosts/vuepress-test/docs/node_modules/stylus-loader/index.js??ref--13-oneOf-1-3!/home/joris/vhosts/vuepress-test/docs/node_modules/@vuepress/core/.temp/style.styl:795:74)
    at __webpack_require__ (/home/joris/vhosts/vuepress-test/docs/node_modules/css-loader/dist/cjs.js??ref--13-oneOf-1-1!/home/joris/vhosts/vuepress-test/docs/node_modules/postcss-loader/src/index.js??ref--13-oneOf-1-2!/home/joris/vhosts/vuepress-test/docs/node_modules/stylus-loader/index.js??ref--13-oneOf-1-3!/home/joris/vhosts/vuepress-test/docs/node_modules/@vuepress/core/.temp/style.styl:21:30)
    at Object.<anonymous> (/home/joris/vhosts/vuepress-test/docs/node_modules/css-loader/dist/cjs.js??ref--13-oneOf-1-1!/home/joris/vhosts/vuepress-test/docs/node_modules/postcss-loader/src/index.js??ref--13-oneOf-1-2!/home/joris/vhosts/vuepress-test/docs/node_modules/stylus-loader/index.js??ref--13-oneOf-1-3!/home/joris/vhosts/vuepress-test/docs/node_modules/@vuepress/core/.temp/style.styl:394:1)
    at __webpack_require__ (/home/joris/vhosts/vuepress-test/docs/node_modules/css-loader/dist/cjs.js??ref--13-oneOf-1-1!/home/joris/vhosts/vuepress-test/docs/node_modules/postcss-loader/src/index.js??ref--13-oneOf-1-2!/home/joris/vhosts/vuepress-test/docs/node_modules/stylus-loader/index.js??ref--13-oneOf-1-3!/home/joris/vhosts/vuepress-test/docs/node_modules/@vuepress/core/.temp/style.styl:21:30)
    at Object.<anonymous> (/home/joris/vhosts/vuepress-test/docs/node_modules/css-loader/dist/cjs.js??ref--13-oneOf-1-1!/home/joris/vhosts/vuepress-test/docs/node_modules/postcss-loader/src/index.js??ref--13-oneOf-1-2!/home/joris/vhosts/vuepress-test/docs/node_modules/stylus-loader/index.js??ref--13-oneOf-1-3!/home/joris/vhosts/vuepress-test/docs/node_modules/@vuepress/core/.temp/style.styl:740:28)
    at __webpack_require__ (/home/joris/vhosts/vuepress-test/docs/node_modules/css-loader/dist/cjs.js??ref--13-oneOf-1-1!/home/joris/vhosts/vuepress-test/docs/node_modules/postcss-loader/src/index.js??ref--13-oneOf-1-2!/home/joris/vhosts/vuepress-test/docs/node_modules/stylus-loader/index.js??ref--13-oneOf-1-3!/home/joris/vhosts/vuepress-test/docs/node_modules/@vuepress/core/.temp/style.styl:21:30)
    at /home/joris/vhosts/vuepress-test/docs/node_modules/css-loader/dist/cjs.js??ref--13-oneOf-1-1!/home/joris/vhosts/vuepress-test/docs/node_modules/postcss-loader/src/index.js??ref--13-oneOf-1-2!/home/joris/vhosts/vuepress-test/docs/node_modules/stylus-loader/index.js??ref--13-oneOf-1-3!/home/joris/vhosts/vuepress-test/docs/node_modules/@vuepress/core/.temp/style.styl:85:18
    at Object.<anonymous> (/home/joris/vhosts/vuepress-test/docs/node_modules/css-loader/dist/cjs.js??ref--13-oneOf-1-1!/home/joris/vhosts/vuepress-test/docs/node_modules/postcss-loader/src/index.js??ref--13-oneOf-1-2!/home/joris/vhosts/vuepress-test/docs/node_modules/stylus-loader/index.js??ref--13-oneOf-1-3!/home/joris/vhosts/vuepress-test/docs/node_modules/@vuepress/core/.temp/style.styl:88:10)

and this goes on for quite a bit, with lots of repeated blocks of errors.

Other relevant information

The same thing happens when I try it with yarn btw.

Is probably related / the same as #3061

smori1983 commented 1 year ago

@jorismak

I also got the similar error. But in my case error only occurred in GitHub Actions.

I applied patch to call console.log() to exec() of node_modules/mini-css-extract-plugin/dist/loader.js to get code line which error reported.

'Cannot read property 'prototype' of undefined' caused in below code:

var DOM_EXCEPTION = 'DOMException';
var Error = getBuiltIn('Error');
var NativeDOMException = getBuiltIn(DOM_EXCEPTION);

var $DOMException = function DOMException() {
  ...
};

var DOMExceptionPrototype = $DOMException.prototype = NativeDOMException.prototype; // <--- Here

This is the code of core-js.

I have 2 projects:

I compared installed packages.

npm ls -t core-js
<project1>
└─┬ vuepress@1.9.7
  └─┬ @vuepress/core@1.9.7
    β”œβ”€β”¬ @vue/babel-preset-app@4.5.15
    β”‚ └── core-js@3.20.3 deduped
    └── core-js@3.20.3
npm ls -t core-js
<project2>
└─┬ vuepress@1.9.7
  └─┬ @vuepress/core@1.9.7
    β”œβ”€β”¬ @vue/babel-preset-app@4.5.19
    β”‚ └── core-js@3.25.3 deduped
    └── core-js@3.25.3

I noticed the difference of version of @vue/babel-preset-app, and I tried deployments by fixing installed version like below:

{
  "devDependencies": {
    "@vue/babel-preset-app": "4.5.18"
  }
}

Results were

@vue/babel-preset-app build
4.5.19 Error
4.5.18 OK
4.5.17 OK
4.5.16 OK
4.5.15 OK

You may avoid the build error by fixing version of @vue/babel-preset-app.

4.5.19 was released on 2022/06/28, a few days before you reported this issue.

https://github.com/vuejs/vue-cli/releases/tag/v4.5.19 https://github.com/vuejs/vue-cli/commit/c7fa1cf

Note that I don't understand why this is the problem.

Elm1992 commented 1 year ago

@smori1983 thx!use 4.5.18 solved the problem,I have this problem because I am using windows.atob, which is a little strange.