51.webpack vue-cli创建项目

在上两篇博文中已经安装了node.js、webpack、vue-cli,安装的版本为:

今天通过这篇博文创建项目。

1.选择路径

首先通过命令行进入想要创建项目的路径,例如:

通过e:命令进入盘幅,再经过cd命令进入文件夹。

2.创建项目

通过命令vue init webpack pm,其中pm为你创建项目的项目名称,在执行命令后vue-cli会下载模板,之后进行项目信息设置:

  1.  
    设置项目名称
  2.  
    ? Project name pmtext
  3.  
    设置项目描述
  4.  
    ? Project description intracompany
  5.  
    作者
  6.  
    ? Author hys
  7.  
    ? Vue build ( Use arrow keys)
  8.  
    ? Vue build standalone
  9.  
    设置路由
  10.  
     ? Install vue-router? Yes
  11.  
     
  12.  
     ? Use ESLint to lint your code? No
  13.  
    单元测试
  14.  
     ? Set up unit tests Yes
  15.  
    ? Pick a test runner jest
  16.  
    ? Setup e2e tests with Nightwatch? Yes
  17.  
    ? Should we run `npm install` for you after the project has been created? (recom
  18.  
    ? Should we run `npm install` for you after the project has been created? (recom
  19.  
    ? Should we run `npm install` for you after the project has been created? (recom
  20.  
    ? Should we run `npm install` for you after the project has been created? (recom
  21.  
     
  22.  
    mended) no  (此处应该选择no
  23.  
     
  24.  
    vue-cli · Generated "pmtext".
  25.  
     
  26.  
    # Project initialization finished!
  27.  
    # ========================
  28.  
     
  29.  
    To get started:
  30.  
    提示下一步操作
  31.  
    进入pmtext文件夹
  32.  
     cd pmtext
  33.  
    初始化项目
  34.  
     npm install (or if using yarn: yarn)
  35.  
    运行项目
  36.  
     npm run dev

执行上面内容后即完成了项目的所有内容,按照链接即可打开项目。

bug

如果在执行:

vue init webpack pm 卡死,说明node.js的版本有问题,尝试其他稳定版,即可以解决此问题。

报错:

  1.  
    39365 error code ELIFECYCLE
  2.  
    39366 error errno 1
  3.  
    39367 error [email protected] install: `node install.js`
  4.  
    39367 error Exit status 1
  5.  
    39368 error Failed at the chromedriver@2.38.3 install script.
  6.  
    39368 error This is probably not a problem with npm. There is likely additional logging output above.

解决链接

npm install chromedriver --chromedriver_cdnurl=http://cdn.npm.taobao.org/dist/chromedriver





猜你喜欢

转载自www.cnblogs.com/sqyambition/p/9320755.html