Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

彻底解决"npm install"时各种报错的一种方案 #146

Open
HackyleShawe opened this issue Oct 28, 2022 · 3 comments
Open

彻底解决"npm install"时各种报错的一种方案 #146

HackyleShawe opened this issue Oct 28, 2022 · 3 comments

Comments

@HackyleShawe
Copy link

主要步骤:

  1. 使用vue脚手架新建Vue2项目,将src、static目录下的源代码复制到新建项目的指定位置
  2. 安装相关依赖
  3. 新建vue.config.js,进行如下配置:(1) 关闭eslint;(2) 添加proxy,访问后端(解决跨域问题)

我的环境:

  • Node:16.14.2
  • NPM:8.5.0
  • Vue:vue/cli 5.0.4

安装依赖

安装生产依赖
npm install --save echarts@4.2.0-rc.2
npm install --save js-cookie@2.2.0
npm install --save normalize.css@8.0.0
npm install --save nprogress@0.2.0
npm install --save v-charts@1.19.0
npm install --save v-distpicker@1.0.20
npm install --save vue-router@3.4.9
npm install --save axios@0.26.0
npm install --save vuex@3.6.2
npm install --save element-ui

注意,需要根据NoseJS的版本安装
cnpm install --save-dev node-sass@6.0.1
cnpm install --save-dev sass-loader@10.2.0


// vue.config.js
module.exports = {
  lintOnSave: false,//是否在保存时检查
  devServer: {
    host: 'localhost',//本机ip
    port: 9020,//本项目使用的端口
    open: true,
    proxy: {
      '/': {  //代理别名
          target: 'http://localhost:8080',   //代理目标值
          changeOrigin: true,
          secure: true,
              pathRewrite:{  //替换路径中的/api
              '^/':'/'
          }
          // pathRequiresRewrite: {
          //   '^/api': ''
          // }
      }
    },
    overlay: {
        warning: false,
        errors: true
    }
  },
  runtimeCompiler: true
}
@HackyleShawe
Copy link
Author

注意: 我在一切都搭建完成,执行“npm run serve”后,进入登录页面,报了个错:
image

我的解决方案
image

@ttddss
Copy link

ttddss commented Jul 14, 2023

前端部署的说明:https://www.macrozheng.com/mall/deploy/mall_deploy_web.html

@cherish710
Copy link

cherish710 commented Jul 14, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants