我尝试在 Ubuntu 中使用 Vue CLI 创建 Vue 项目,但不断收到相同的错误。我已经使用
sudo npm i -g @vue/cli
安装了 Vue CLI。
这是错误消息:
00h00m00s 0/0: : 错误错误:命令失败:yarn config 获取注册表 错误:[Errno 2] 没有这样的文件或目录:“config”
错误:命令失败:yarn config 获取注册表
错误:[Errno 2]没有这样的文件或目录:'config'
在 makeError (/usr/local/lib/node_modules/@vue/cli/node_modules/execa/index.js:174:9) 在 Promise.all.then.arr (/usr/local/lib/node_modules/@vue/cli/node_modules/execa/index.js:278:16) 在 processTicksAndRejections (内部/process/next_tick.js:81:5)
这是什么原因?
根据
error
,它试图在node_modules
中找到yarn的配置文件。我相信您的系统中没有安装 yarn
packageManager
试试这个
vue config -s packageManager npm
然后重新运行
vue create
a) 卸载yarn,因此 create 将回退到 npm
b) 明确告诉它使用 npm:
vue create myproject --packageManager npm
卸载node和npm,然后重新启动我的电脑,然后重新安装它们对我有用。
sudo apt remove nodejs
sudo apt autoremove
重新安装
sudo apt install nodejs
sudo apt install npm
以下内容对我有帮助。 即使纱线已经安装了,我还是跑了
npm install -g yarn
并重复
vue create project-name