本文主要是介绍Mac安装webpack步骤,失败npm ERR! Error: EACCES: permission denied, access,亲测有效,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
安装webpack步骤
- Mac在终端先获取root权限
在mac下依赖包要写入系统重要文件夹里,由于没有先获取root权限所以写入失败,导致安装失败。失败显示:
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.npm ERR! A complete log of this run can be found in:
npm ERR! /Users/gaorongrong/.npm/_logs/2021-08-08T08_34_15_754Z-debug.log
$ sudo -s
回车,输入密码即可
- 直接下载webpack会很慢,建议先下载国内镜像
npm install -g cnpm --registry=http://registry.npm.taobao.org
- 用cnpm下载webpack(全局安装webpack,如果之前安装过webpack或安装失败,先卸载:cnpm uninstall webpack -g)
cnpm install webpack@3.6.0 -g
(指定版本号3.6.0,因为vue cli2依赖该版本)
4.查看安装成功的版本号
webpack --version
这篇关于Mac安装webpack步骤,失败npm ERR! Error: EACCES: permission denied, access,亲测有效的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!