使用 CLI 创建 vue 项目时出错

Error when creating a vue project with CLI

我正在尝试在 Ubuntu 中使用 Vue CLI 创建一个 Vue 项目,但一直出现相同的错误。我已经使用 sudo npm i -g @vue/cli.

安装了 Vue CLI

错误信息如下:

00h00m00s 0/0: : ERROR Error: Command failed: yarn config get registry ERROR: [Errno 2] No such file or directory: 'config'

Error: Command failed: yarn config get registry

ERROR: [Errno 2] No such file or directory: 'config'

at makeError (/usr/local/lib/node_modules/@vue/cli/node_modules/execa/index.js:174:9) at Promise.all.then.arr (/usr/local/lib/node_modules/@vue/cli/node_modules/execa/index.js:278:16) at processTicksAndRejections (internal/process/next_tick.js:81:5)

这是什么原因?

安装 yarn so create 将回退到 npm

b) 明确告诉它使用 npm:

vue create myproject --packageManager npm 

根据 error 它试图在 node_modules 中找到 yarn 的配置文件。我相信你的系统中没有安装 yarn packageManager

试试这个 vue config -s packageManager npm

再运行vue create

卸载节点和 npm 然后重新启动我的电脑,然后重新安装它们对我有用。

sudo apt remove nodejs

sudo apt autoremove

正在重新安装

sudo apt install nodejs

sudo apt install npm