Back

安装使用vuejs

发布时间: 2016-06-13 01:41:00

参考: http://vuejs.org.cn/guide/installation.html

先安装 nvm,  然后安装最新版本的 node  ( $ nvm use v6.2.1) ,我安装的是 6.2.1

再安装 vue 和  vue 的命令行:

$ cnpm install vue

$ cnpm install -g vue-cli --verbose

接下来,就可以创建vue 项目了:

sg552@siwei-i7-book:/workspace$ vue init webpack test-vue

? Project name test-vue
? Project description A Vue.js project
? Author Siwei < [email protected]>
? Use ESLint to lint your code? Yes
? Pick an ESLint preset Standard
? Setup unit tests with Karma + Mocha? Yes
? Setup e2e tests with Nightwatch? Yes

   vue-cli · Generated "test-vue".

   To get started:
   
     cd test-vue
     npm install
     npm run dev
   
   Documentation can be found at https://vuejs-templates.github.io/webpack

然后, 进入到项目中,发现package.json 也创建了。创建了不少 node package. 

所以我们要安装它:

$ cd test-vue
$ cnpm install --verbose (可以看到安装package的进程)

[email protected] /workspace/test-vue
├─┬ [email protected] 
│ ├─┬ [email protected] 
│ │ └── [email protected] 
│ ├─┬ [email protected] 
│ │ ├─┬ [email protected] 
│ │ │ └─┬ [email protected] 
│ │ │   └── [email protected] 
│ │ └── [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ ├─┬ [email protected] 
( 此处省略30屏)
    └─┬ [email protected] 
      ├── [email protected] 
      └── [email protected] 

npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]
npm verb exit [ 0, true ]
npm info ok 

然后,输入启动命令,发现就跑起来了:

sg552@siwei-i7-book:/workspace/test-vue$ npm run dev

> [email protected] dev /workspace/test-vue
> node build/dev-server.js

Listening at http://localhost:8080

webpack built 1e6ddc6a74121a19e6fa in 2827ms
Hash: 1e6ddc6a74121a19e6fa
Version: webpack 1.13.1
Time: 2827ms
     Asset       Size  Chunks             Chunk Names
    app.js    1.06 MB       0  [emitted]  app
index.html  241 bytes          [emitted]  
Child html-webpack-plugin for "index.html":
         Asset     Size  Chunks       Chunk Names
    index.html  21.4 kB       0       
webpack: bundle is now VALID.

Vue Index

发布: 

$ npm run build 

就会把文件打包到 dist 目录下。

sg552@siwei-i7-book:/workspace/test-vue$ npm run build

> [email protected] build /workspace/test-vue
> node build/build.js

  Tip:
  Built files are meant to be served over an HTTP server.
  Opening index.html over file:// won't work.

Hash: a29da41b1f02680e9b0c
Version: webpack 1.13.1
Time: 4268ms
                                                  Asset       Size  Chunks             Chunk Names
             static/js/manifest.6d4f7691d281e9668e31.js  838 bytes       0  [emitted]  manifest
                  static/js/app.c74152b60387f00140e7.js    11.2 kB    1, 0  [emitted]  app
               static/js/vendor.27fc975b9a336a8f5d73.js    79.4 kB    2, 0  [emitted]  vendor
    static/css/app.649c105cdf4209683036841d77ad6f25.css  505 bytes    1, 0  [emitted]  app
         static/js/manifest.6d4f7691d281e9668e31.js.map    8.88 kB       0  [emitted]  manifest
              static/js/app.c74152b60387f00140e7.js.map    30.2 kB    1, 0  [emitted]  app
static/css/app.649c105cdf4209683036841d77ad6f25.css.map    1.28 kB    1, 0  [emitted]  app
           static/js/vendor.27fc975b9a336a8f5d73.js.map     682 kB    2, 0  [emitted]  vendor
                                             index.html  438 bytes          [emitted]  

Back