欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Vue-admin-template后台管理部署和启动前报错的坑

程序员文章站 2022-03-26 21:39:00
...

1.启动经常报错


    E:/IdeaProjects/guli-vue-admin/index.html:17257:11

  - index.html:17262 Q3Bv.module.exports
    E:/IdeaProjects/guli-vue-admin/index.html:17262:3

  - index.js:286 HtmlWebpackPlugin.executeTemplate
    [guli-vue-admin]/[html-webpack-plugin]/index.js:286:14

  - index.js:176
    [guli-vue-admin]/[html-webpack-plugin]/index.js:176:20



  Build failed with errors.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! aaa@qq.com build: `node build/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the aaa@qq.com build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     D:\DevelopTool\nodejs\node_cache\_logs\2020-10-27T06_51_56_811Z-debug.log

E:\IdeaProjects\guli-vue-admin>

重要的一句话是:This is probably not a problem with npm. There is likely additional logging output above.

解决办法:

rm -rf node_modules

rm -rf package-lock.json

npm cache clear --force

npm install

npm run build

2.打包显示

Tip: built files are meant to be served over an HTTP server.

  Opening index.html over file:// won't work.

Vue-admin-template后台管理部署和启动前报错的坑

Vue-admin-template后台管理部署和启动前报错的坑

 

原因:

npm run dev是开发环境, npm run build是生产环境, 在开发环境完成代码和测试, 之后用生产环境生成代码,

npm run build的时候, 一开始就会提示Built files are meant to be served over an HTTP server. Opening index.html over file:// won't work., 因为vue-cli的默认配置中, publishPath是用绝对目录, 所以dist文件夹里的文件必须放在服务器的根目录, 如果你想本地打开的话, 可以在npm run build完成之后执行以下命令:

cd dist

npm install -g http-server // 该命令只需执行一次, 安装过之后, 以后就不需要重复安装了.

hs

 

相关标签: 打包部署 vue