webpack - 从 0.X 迁移到 1.2.0 后,Vuepress 构建失败
问题描述
我遵循了 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
except中的所有依赖项vuepress
,重新安装所有依赖项,错误消失。我对此不熟悉,但我认为这可能是版本控制的问题core-js
,vuepress
仍在使用2.x而您正在使用3.x
vuepress
迁移到1.2.0的另一个问题是vuepress
默认情况下不附带一些官方插件。所以需要手动安装vuepress-plugin-pwa才能使用。查看文档以获取更多详细信息。
顺便说一句,我注意到你在你的回购中都有package-lock.json
,yarn.lock
所以我不确定你使用的是哪个工具。目前,yarn
是推荐的方式,因为npm
在某些情况下可能会导致一些错误。
推荐阅读
- php - 如何检查子数组中的值?
- javascript - 如何在不创建循环的情况下使 clearInterval 停止?
- javascript - 为我的 API 应用程序获取 Auth0 用户管理 API 令牌
- spring-boot - Spring Cloud Gateway,如何更改超出请求限制的错误状态类型?
- javascript - 每周数据未在 amCharts 烛台图表中正确显示
- macos - 为 OSX 编写和公证可执行文件
- css - CSS使用网格垂直居中不起作用
- reactjs - Reactjs Snackbar 显示自己的进度
- javascript - Ajax 使用 jQuery 和 webkit 浏览器上传文件文件夹
- nginx - 代码服务器 (docker) 和 nuxt.js / javascript 404