Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用Vue CLI创建typescript项目 #2

Open
freyhill opened this issue Aug 8, 2019 · 0 comments
Open

使用Vue CLI创建typescript项目 #2

freyhill opened this issue Aug 8, 2019 · 0 comments

Comments

@freyhill
Copy link
Owner

freyhill commented Aug 8, 2019

使用最新的Vue CLI @vue/cli创建typescript项目,使用vue -V查看当前的vue cli版本

安装命令

npm install -g @vue/cli

创建项目

vue create my-vue-typescript

1

上下键选择,空格键确定
2

接下来是一些常规选项

3

下面是询问要不要记录这次配置以便后面直接使用,我们选择y

4

当确定配置后会在C:\Users\Administrator\.vuerc下生成一个刚选好的配置记录

{
  "useTaobaoRegistry": true,
  "presets": {
    "my-vue-typescript": {
      "useConfigFiles": true,
      "plugins": {
        "@vue/cli-plugin-babel": {},
        "@vue/cli-plugin-typescript": {
          "classComponent": true,
          "tsLint": true,
          "lintOn": [
            "save"
          ],
          "useTsWithBabel": true
        }
      },
      "router": true,
      "routerHistoryMode": true,
      "vuex": true
    }
  }
}

然后再回车就开始创建项目,但是这里却报了一个错,大概意思是源有问题。

ERROR  command failed: yarn --registry=https://registry.npm.taobao.org --disturl=https://npm.taobao.org/dist

于是搜了下原因,原来是创建时候的默认源配置导致,vue cli 安装报错问题解决
5

所以修改下刚才生成的.vuerc下的useTaobaoRegistry属性值为false就可以了

{
  "useTaobaoRegistry": false,
   ...
}

再次安装成功

@freyhill freyhill changed the title vue-typescript安装失败总结 window下Vue CLI创建typescript项目失败总结 Aug 8, 2019
@freyhill freyhill changed the title window下Vue CLI创建typescript项目失败总结 windows下Vue CLI创建typescript项目失败总结 Aug 8, 2019
@freyhill freyhill changed the title windows下Vue CLI创建typescript项目失败总结 windows下Vue CLI创建typescript项目 Aug 8, 2019
@freyhill freyhill changed the title windows下Vue CLI创建typescript项目 使用Vue CLI创建typescript项目 Aug 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant