Vue项目运行配置

来源:互联网 发布:java消息队列 编辑:程序博客网 时间:2024/06/16 01:29

1、vue项目的构建过程

安装vue

root:vueWork root$ npm install vue+ vue@2.5.9added 1 package in 10.749sroot:vueWork root$ vue -V2.9.1

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

root:vueWork root$ node -vv6.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-clinpm 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.2updated 3 packages in 44.243sroot:vueWork root$ vue init webpack myProjectProject name testProject description A Vue.js projectAuthor xianglingchuan <xianglingchuan@sina.cn>Vue build standaloneInstall vue-router? YesUse ESLint to lint your code? YesPick an ESLint preset StandardSet up unit tests YesPick a test runner jestSetup 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.lognohup: ignoring input and redirecting stderr to stdout[1]+  Stopped                 nohup npm run start > /log/settleWebApp.log

执行命令修改为:

nohup npm run dev > /chroot/wwwlogs/settleWebApp.log &
原创粉丝点击