Vue项目运行配置

1、vue项目的构建过程

安装vue

root:vueWork root$ npm install vue
+ vue@2.5.9
added 1 package in 10.749s
root:vueWork root$ vue -V
2.9.1

vue依赖于node.js,需要确保计算机已经安装了node.js.

root:vueWork root$ node -v
v6.11.4
全局安装vue-cli

npm install –global vue-cli

创建一个基于webpack模板的新基目

vue init webpack myProject

安装依赖

cd myProject
npm install
npm run dev

安装成功提示

root:vueWork root$ npm install --global vue-cli
npm WARN deprecated coffee-script@1.12.7: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
/usr/local/bin/vue-init -> /usr/local/lib/node_modules/vue-cli/bin/vue-init
/usr/local/bin/vue -> /usr/local/lib/node_modules/vue-cli/bin/vue
/usr/local/bin/vue-list -> /usr/local/lib/node_modules/vue-cli/bin/vue-list
+ vue-cli@2.9.2
updated 3 packages in 44.243s

root:vueWork root$ vue init webpack myProject
Project name test
Project description A Vue.js project
Author xianglingchuan <xianglingchuan@sina.cn>
Vue build standalone
Install vue-router? Yes
Use ESLint to lint your code? Yes
Pick an ESLint preset Standard
Set up unit tests Yes
Pick a test runner jest
Setup e2e tests with Nightwatch? Yes

   vue-cli · Generated "myProject".

   To get started:

     cd myProject
     npm install
     npm run dev

   Documentation can be found at https://vuejs-templates.github.io/webpack

2、vue项目后台运行命令

命令: nohup npm run dev > /dev/null &

3、修改运行端口号

config/index.js文件中

dev: {
    env: require('./dev.env'),
    port: 8080,
    autoOpenBrowser: true,
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    proxyTable: {
        '/mock': {
            target: 'http://localhost:3000',
            changeOrigin: true,
            pathRewrite: {
                '^/mock': ''
            }
        },
        '/api': {
            target: 'http://localhost:3000',
            changeOrigin: true,
            cookieDomainRewrite: {
              "*": "*",
            },
            onProxyReq: function (proxyReq, req, res) {

            },
            onProxyRes: function (proxyRes, req, res) {
                let existingCookies = proxyRes.headers['set-cookie'],
                rewrittenCookies = [];
                if (existingCookies !== undefined) {
                    if (!Array.isArray(existingCookies)) {
                        existingCookies = [existingCookies];
                    }
                    for (let i = 0; i < existingCookies.length; i++) {
                         rewrittenCookies.push(existingCookies[i].replace(/;\s*?(Secure)/i, ''));
                    }
                    proxyRes.headers['set-cookie'] = rewrittenCookies;
                }
            }
        }
    },
    cssSourceMap: false
  }

执行命令报: nohup: ignoring input and redirecting stderr to stdout

[root@iZuf6 webapp]# nohup npm run dev >  /log/settleWebApp.log
nohup: ignoring input and redirecting stderr to stdout
[1]+  Stopped                 nohup npm run start > /log/settleWebApp.log

执行命令修改为:

nohup npm run dev > /chroot/wwwlogs/settleWebApp.log &
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值