我的 npm install -g react-native-cli 不起作用

Aav*_*kar 1 node.js npm reactjs react-native react-native-ios

它说需要许可,我无法获得许可。由于这个问题,我无法在我的 Mac 上运行 react-native。

一世?试图获得权限但不能。

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules

npm ERR! path /usr/local/lib/node_modules

npm ERR! code EACCES

npm ERR! errno -13

npm ERR! syscall access

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!   stack:

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! 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!     /Users/aaviskarpokhrel/.npm/_logs/2019-07-21T04_35_00_756Z-debug.log
Run Code Online (Sandbox Code Playgroud)

Tie*_*ong 5

您需要使用 sudo 命令全局安装模块。

sudo npm install -g react-native-cli
Run Code Online (Sandbox Code Playgroud)