MAC上安装angular时碰到的一些问题
2020-05-15 23:16
176 查看
想在mac上安装angular,中途碰到一些问题,现已解决。特此分享,供参考。
我一开始用如下命令直接安装:
npm install -g @angular/cli
安装过程中碰到如下的报错1:
xxxdeMBP:~ xxx$ npm install -g @angular/clinpm WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning undefined: network timeout at: https://registry.npmjs.org/@angular-devkit%2fcore npm WARN registry Using stale data from https://registry.npmjs.org/ due to a request error during revalidation. npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules 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/yangmuxue/.npm/_logs/2020-05-15T14_23_03_431Z-debug.log
报错1的解决方法:
由于报错显示路径’/usr/local/lib/node_modules’存在权限问题,于是我用以下命令查看了这个文件的拥有者:
xxxxdeMBP:_logs xxxx$ ls -la /usr/local/lib/node_modules total 0 drwxr-xr-x 3 root wheel 96 5 15 22:18 . drwxr-xr-x 5 root wheel 160 5 15 22:18 .. drwxr-xr-x 24 root wheel 768 4 28 19:15 npm
这个文件的拥有者是root,所以我当前的身份不能进行修改。于是我修改了这些文件的拥有者。
sudo chown -R xxxx(新的拥有者): /usr/local/lib/node_modules
再次查看文件权限:
xxxxdeMBP:_logs xxxx$ ls -la /usr/local/lib/node_modules total 0 drwxr-xr-x 3 xxxx wheel 96 5 15 22:18 . drwxr-xr-x 5 root wheel 160 5 15 22:18 .. drwxr-xr-x 24 xxxx wheel 768 4 28 19:15 npm
虽然仍然有一个文件的拥有者是root,当我始终改不掉。于是尝试性地重新安装,可又遇到了报错2:
xxxxdeMBP:~ xxxx$ npm install -g @angular/clinpm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 npm ERR! code EACCES npm ERR! syscall symlink npm ERR! path ../lib/node_modules/@angular/cli/bin/ng npm ERR! dest /usr/local/bin/ng npm ERR! errno -13 npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/@angular/cli/bin/ng' -> '/usr/local/bin/ng' npm ERR! [OperationalError: EACCES: permission denied, symlink '../lib/node_modules/@angular/cli/bin/ng' -> '/usr/local/bin/ng'] { npm ERR! cause: [Error: EACCES: permission denied, symlink '../lib/node_modules/@angular/cli/bin/ng' -> '/usr/local/bin/ng'] { npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'symlink', npm ERR! path: '../lib/node_modules/@angular/cli/bin/ng', npm ERR! dest: '/usr/local/bin/ng' npm ERR! }, npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'symlink', npm ERR! path: '../lib/node_modules/@angular/cli/bin/ng', npm ERR! dest: '/usr/local/bin/ng' 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/yangmuxue/.npm/_logs/2020-05-15T14_44_36_347Z-debug.log
报错2的解决方法:用如下命令重新安装:
sudo npm install -g @angular/cli
我的安装到此就成功了。以上分享供小伙伴们参考!
相关文章推荐
- Windows xp下安装sql server2005所碰到的一些问题及解决方法
- mysql 安装过程中碰到的一些问题
- 配置mac 环境时碰到的一些问题
- 安装Eclipse和Lomboz碰到的一些问题
- CentOS 7 下安装oracle 11g碰到的一些问题
- 关于本人在VMware安装MAC碰到的问题和解决办法
- Mac上php和mysql的安装以及一些配置问题解决
- 安装Mysql碰到的一些问题。
- Mac系统sublime text3 安装与使用中遇到的一些问题及解决方案
- [转]在VS2008上安装WTL8.1时碰到的一些问题
- 安装Eclipse和Lomboz碰到的一些问题
- mac mysql apache 碰到的一些问题
- CDH5实践(四)Cloudera Manager 5安装中碰到的一些问题和解决办法
- Faster-Rcnn caffe 安装碰到的一些问题(ubuntu 16.04环境下)
- 在Mac上安装pyv8碰到的问题。
- Mac上Oracle数据库的安装及过程中一些问题的解决
- .NET Framework 4.0 安装SQLite Provider碰到的一些问题
- mac(10.7.5)安装qt5.2碰到的问题总结
- 安装JDK11与Eclipse碰到的一些问题
- MAC安装chromedriver碰到的问题