场景:
我按照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 然后把它删掉。