今天在使用express -e . 的命令时,cmd给我报了一段不识别的错误:

bash: express: command not found

,在网上查了一下,有人指出是express4的版本将命令工具分家了,所以需要我们安装以命令工具:

命令如下:npm install -g express-generator

之后再次安装:npm install -g express

好了,没问题了。

vue连接数据库调接口:

1.在code中安装:express server -e

2.进入server: cd server

3.安装依赖:cnpm i

4.vuex->code->server->app.js添加:

  1. //监听端口
    app.listen(777,()=>{
    console.log('服务器已经启动...')
    });

5.启动 nodemon app

如果显示bash:nodemon:command not found

执行以下命令:

   cnpm install -g nodemon

6.引入axios并挂载在vue的原型上

  1. npm install axios --save
  2.  
  3. main.js中引入
  1. import axios from 'axios'
  1. Vue.prototype.axios = axios;

在相应页面测试:

  1. this.axios.get('/api/voteindex')
    .then(response => {
    if(response.data.length){
    console.log('接收后端响应登录请求的数据',response.data[0]);
    }else{
    _this.$message.error('请检查用户名和密码');
    }
    })

7.vuex->code-vuexms->config->index.js中的dev里配置proxyTable:

  1. proxyTable: {
    '/api':{
    target: 'http://localhost:777/', // 测试
    changeOrigin: true, // 改变源(是否跨域)
    pathRewrite: {
    '^/api': '/'
    }
    }
    }

  1.  

8.引入请求

  1. vuex->code-server->routes->index.js引入:
  1.  
  1. router.get('/voteindex',(req,res) =>{
    res.send("111")
    });

9.用node.js连接数据库,启动phpStudy

  1. server中安装mysql
  1. cnpm install mysql --save

vuex->code-server->routes中新建conn.js

  1. //引入mysql
    const mysql = require('mysql');
    var connection = mysql.createConnection({
    host : 'localhost',
    user : 'root',
    password : '',
    database : 'vuexms'
    });
  2.  
  3. //暴露出去
    module.exports = connection;
    // connection.connect();

10.在vuex->code-server->routes->index.js连接数据库

  1. //引入连接数据模块
    const connection =require('./conn');
    // //连接数据
    connection.connect(() => {
    console.log("数据库连接成功")
    });

  1.  
  1.  

bash: express: command not found及vue连接数据库调接口的更多相关文章

  1. bash:express:command not found

    重新设置了node_global和node_cache目录后,总是显示command not found 找了几篇博文后,终于解决了这个问题   步骤如下: 1.新建node_global和node_ ...

  2. scp报错 -bash: scp: command not found

    环境:RHEL6.5 使用scp命令报错: [root@oradb23 media]# scp /etc/hosts oradb24:/etc/ -bash: scp: command not fou ...

  3. source /etc/profile报错-bash: id:command is not found

    由于误操作导致 source /etc/profile 报错 -bash: id:command is not found 此时,linux下很多命令到不能能用,包括vi ls 等... 可以使用 e ...

  4. -bash: .bash_profile: command not found

    今天有一同事安装了ORACLE后,在切换账号时遇到错误提示"-bash: .bash_profile: command not found".如下所示 [root@GLETestL ...

  5. Linux下提示 bash: xxx command not found

    今天在虚拟机上安装了CentOS5.5,发现运行一些很正常的诸如:init,shutdown,fdisk 等命令时,悍然提示: bash: xxx command not found. 那么,首先就要 ...

  6. [原创]-bash: iostat: command not found解决办法

    [root@testhost ~]# iostat-bash: iostat: command not found IOSTAT 命令不可用,首先确认sysstat包是否安装,sysstat包中包括i ...

  7. # mysql -u root -p -bash: mysql: command not found

    [root@jboss ~]# mysql -u root -p-bash: mysql: command not found 需要安装mysql # yum install mysql之后就行 了

  8. bash:fdisk:command not found

    bash:fdisk:command not found [lansir@Red-Hat ~]$ fdisk -l-bash: fdisk: command not found 原因是fdisk不在P ...

  9. Centos提示-bash: make: command not found的解决办法

    一般出现这个-bash: make: command not found提示,是因为安装系统的时候使用的是最小化mini安装,系统没有安装make.vim等常用命令,直接yum安装下即可: yum - ...

随机推荐

  1. Python collection模块与深浅拷贝

    collection模块是对Python的通用内置容器:字典.列表.元组和集合的扩展,它包含一些专业的容器数据类型: Counter(计数器):dict子类,用于计算可哈希性对象的个数. Ordere ...

  2. 第六篇:fastJson常用方法总结

    1.了解json json就是一串字符串 只不过元素会使用特定的符号标注. {} 双括号表示对象 [] 中括号表示数组 "" 双引号内是属性或值 : 冒号表示后者是前者的值(这个值 ...

  3. 第四周课堂笔记1th

    函数   关键字def   函数名加括号  是调用函数   Return   相当于给函数算完之后给予另一个返回值   返回的是元组 如果return后没写返回none Return在函数中可以结束整 ...

  4. USACO 2007 February Silver The Cow Lexicon /// DP oj24258

    题目大意: 输入w,l: w是接下来的字典内的单词个数,l为目标字符串长度 输入目标字符串 接下来w行,输入字典内的各个单词 输出目标字符串最少删除多少个字母就能变成只由字典内的单词组成的字符串 Sa ...

  5. 2019 Multi-University Training Contest 6 Nonsense Time (纯暴力)

    题意:给你一个n的排列,起初这些数都不能用, 然后还有一个数组 第 i 个数表示下标为 i 的数能够使用. 问每一个 i 对应的最长上升子序列. 题解: 可以通过倒推,从后往前考虑转化一下 ,然后就是 ...

  6. (十一)Json文件配置

    接上一节,新建一个项目:JsonConfigSample 依然添加Microsoft.AspNetCore.All 在项目下新建一个Class.json配置文件 { ", "Cla ...

  7. 课程笔记-lisanke

    1.判断真需求假需求 真需求:所有人都需要的功能 假需求:只有自己需要的功能 2.找到目标用户 ①不要直接询问是否需要这个功能 ②旁敲侧击式提问:用户使用了什么方式?之前都是怎么做的? case:购物 ...

  8. java开发系列-服务器tomcat

    概述 tomcat是Apache组织提供的,中小型的免费的支持Servlet和JSP规范的服务器. tomcat安装配置 下载 官方下载地址 下载,绿色版直接解压到指定目录就好. 启动Tomcat 双 ...

  9. Vagrant box ubuntu/xenial64 添加vagrant用户解决没有登录密码的问题

    参考了Vagrant box ubuntu/xenial64 の ubuntuユーザ の passwordについて 1. 可以通过 Git Bash 使用  vagrant ssh 登录到Ubuntu ...

  10. 二分图——多重匹配模板hdu1669

    好像多重匹配一般是用网络流来做的.. 这是匈牙利算法的模板:lim是每个组的上界 思路是每个组都可以匹配lim个点,那么当点x遇到的组匹配的点数还没有超过lim时,直接匹配即可 如果已经等于了lim, ...