每当我键入并尝试在Ubuntu计算机上安装React Native时,我都会使用以下代码:
npm install -g expo-cli
然后我执行代码,并得到此错误:
npm WARN checkPermissions Missing write access to
/usr/lib/node_modules
npm ERR! path /usr/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access
'/usr/lib/node_modules'
npm ERR! { [Error: EACCES: permission denied, access
'/usr/lib/node_modules']
npm ERR! stack:
npm ERR! "Error: EACCES: permission denied, access
'/usr/lib/node_modules'",
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/lib/node_modules' }
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 (though this is not
recommended).
npm ERR! A complete log of this run can be found in:
npm ERR! /home/atharva/.npm/_logs/2019-01-19T15_37_39_233Z-debug.log
答案 0 :(得分:0)
尝试sudo npm install -g expo-cli
。
与权限相关的问题可以通过root
权限来解决。
但是从npmjs官方文档中推荐使用此方法。
另一个与您相同的问题:https://stackoverflow.com/a/49122289/515932
官方:https://docs.npmjs.com/getting-started/fixing-npm-permissions
答案 1 :(得分:0)
如果您使用过:
sudo npm install -g expo-cli
命令,仍然出现相同的问题, 首先,请检查npm,expo和react-native是否正确安装。
npm -v
expo --version
react-native --version
遵循以下说明之一:
转到root,然后输入以下命令:
sudo su
npm install -g expo-cli
作为普通用户使用此命令来安装expo-cli:
sudo npm install -g --unsafe-perm expo-cli
希望这可以帮助您解决问题。