Mac下使用Vue-cli搭建脚手架,npm install报错问题之解决

首先使用这条命令初始化项目

vue init <template-name> <project-name>

然后使用npm install安装项目依赖包。
总是报错,本来以为权限问题,使用sudo npm install也还是不行。

看到网上说可能会有网络问题,所以可以使用cpm,也就是用淘宝的源。在淘宝网站上找到安装方法:

npm install -g cnpm --registry=https://registry.npm.taobao.org

可是还是错了,加上sudo也不行。

想到刚才多次运行npm,可能需要清理一下缓存,于是:

npm cache clean --force
sudo npm install -g cnpm --registry=https://registry.npm.taobao.org
sudo cnpm install

安装成功,完美!

猜你喜欢

转载自blog.csdn.net/weixin_34289744/article/details/91000519