从 0.X 迁移到 1.2.0 后 Vuepress 构建失败

Vuepress build failed after migrating from 0.X to 1.2.0

我按照vuepress网站上的官方升级指南进行操作。 https://vuepress.vuejs.org/miscellaneous/migration-guide.html

当我 运行 yarn docs:dev 我得到这个输出:

tip Apply theme @vuepress/theme-default ...
tip Apply plugin container (i.e. "vuepress-plugin-container") ...
tip Apply plugin @vuepress/last-updated (i.e. "@vuepress/plugin-last-updated") ...
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") ...
tip Apply plugin @vuepress/pwa (i.e. "@vuepress/plugin-pwa") ...
tip Apply plugin vuepress-plugin-anonymous-3d39fa1d ...

* Client █████████████████████████ building (42%) 271/275 modules 4 active
 node_modules\lodash\_root.js

i 「wds」: Project is running at http://0.0.0.0:8080/
i 「wds」: webpack output is served from /docs/
i 「wds」: Content not from webpack is served from c:\dsasd\docs\.vuepress\public
i 「wds」: 404s will fallback to /index.html
Language does not exist bat

当我在浏览器中打开端口 8080 时,它显示一堆错误。

当我 运行 yarn docs:build 我得到这个输出:

Error: Failed to compile with errors.
    at webpack (c:\dsasd\node_modules\@vuepress\core\lib\node\build\index.js:186:16)
    at finalCallback (c:\dsasd\node_modules\@vuepress\core\node_modules\webpack\lib\MultiCompiler.js:254:12)
    at runWithDependencies.err (c:\dsasd\node_modules\@vuepress\core\node_modules\webpack\lib\MultiCompiler.js:277:6)
    at done (c:\dsasd\node_modules\neo-async\async.js:2931:13)
    at runCompilers (c:\dsasd\node_modules\@vuepress\core\node_modules\webpack\lib\MultiCompiler.js:181:48)
    at err (c:\dsasd\node_modules\@vuepress\core\node_modules\webpack\lib\MultiCompiler.js:188:7)
    at compiler.run (c:\dsasd\node_modules\@vuepress\core\node_modules\webpack\lib\MultiCompiler.js:270:7)
    at finalCallback (c:\dsasd\node_modules\@vuepress\core\node_modules\webpack\lib\Compiler.js:257:39)
    at hooks.done.callAsync.err (c:\dsasd\node_modules\@vuepress\core\node_modules\webpack\lib\Compiler.js:273:13)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (c:\dsasd\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:33:1)  
    at AsyncSeriesHook.lazyCompileHook (c:\dsasd\node_modules\tapable\lib\Hook.js:154:20)
    at onCompiled (c:\dsasd\node_modules\@vuepress\core\node_modules\webpack\lib\Compiler.js:271:21)
    at hooks.afterCompile.callAsync.err (c:\dsasd\node_modules\@vuepress\core\node_modules\webpack\lib\Compiler.js:681:15)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (c:\dsasd\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)   
    at AsyncSeriesHook.lazyCompileHook (c:\dsasd\node_modules\tapable\lib\Hook.js:154:20)
    at compilation.seal.err (c:\dsasd\node_modules\@vuepress\core\node_modules\webpack\lib\Compiler.js:678:31)
error Command failed with exit code 1.

有什么解决办法或建议吗?

好吧,我认为您的依赖性冲突导致了错误。删除 package.json 中除 vuepress 之外的所有依赖项,重新安装所有依赖项,错误消失。我对此不熟悉,但我认为这可能是 core-js 的版本控制问题,vuepress 仍在使用 2.x 并且您正在使用 3.x

迁移到 vuepress 1.2.0 的另一个问题是某些官方插件默认情况下未随 vuepress 一起提供。因此,您需要手动安装 vuepress-plugin-pwa to use it. Check out the document 以获得更多详细信息。

顺便说一句,我注意到您的存储库中同时包含 package-lock.jsonyarn.lock,所以我不确定您使用的是哪个工具。目前,yarn是推荐的方式,因为npm在某些情况下可能会导致一些错误。