首页 前端知识 vuepress开发npm run dev时正常,打包npm run build时报错

vuepress开发npm run dev时正常,打包npm run build时报错

2024-07-21 00:07:21 前端知识 前端哥 572 68 我要收藏

场景:

我按照vuepress文档搭建了自己的博客
npm run dev 开发的时候正常,但是要部署时 npm run build 打包发生了报错


问题描述:

Error: Cannot find module ‘F:\3.Project\1.VS Code project\5.vuepress-blog\vuepress-blog\dist\manifest\client.json’

具体的报错信息如下

Error: Cannot find module 'F:\3.Project\1.VS Code project\5.vuepress-blog\vuepress-blog\dist\manifest\client.json'
Require stack:
- F:\3.Project\1.VS Code project\5.vuepress-blog\vuepress-blog\node_modules\_@vuepress_core@1.9.7@@vuepress\core\lib\node\build\index.js
- F:\3.Project\1.VS Code project\5.vuepress-blog\vuepress-blog\node_modules\_@vuepress_core@1.9.7@@vuepress\core\lib\node\App.js
- F:\3.Project\1.VS Code project\5.vuepress-blog\vuepress-blog\node_modules\_@vuepress_core@1.9.7@@vuepress\core\lib\index.js
- F:\3.Project\1.VS Code project\5.vuepress-blog\vuepress-blog\node_modules\_vuepress@1.9.7@vuepress\lib\registerCoreCommands.js
- F:\3.Project\1.VS Code project\5.vuepress-blog\vuepress-blog\node_modules\_vuepress@1.9.7@vuepress\cli.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:747:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Build.render (F:\3.Project\1.VS Code project\5.vuepress-blog\vuepress-blog\node_modules\_@vuepress_core@1.9.7@@vuepress\core\lib\node\build\index.js:57:28)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async App.build (F:\3.Project\1.VS Code project\5.vuepress-blog\vuepress-blog\node_modules\_@vuepress_core@1.9.7@@vuepress\core\lib\node\App.js:499:5)

原因分析:

我以前学习 node.js 时,在系统环境变量,设置过一个 NODE_ENV=development, 而 vuepress 在你执行npm run dev和npm run build命令时,就会去查找系统环境变量,假如你曾经手动设置了NODE_ENV=development那不管你执行哪条命令,他都会以development模式运行打包,所以run dev不报错,但run build就报错了

解决方案:

去系统环境变量出找到 NODE_ENV 然后把它删掉。
在这里插入图片描述

转载请注明出处或者链接地址:https://www.qianduange.cn//article/14148.html
标签
评论
发布的文章

JQuery中的load()、$

2024-05-10 08:05:15

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!