我已经在根目录下的ubuntu 20.04上下载了expo cli,但无法在全球范围内下载它!我希望expo cli全局存在,因为不建议通过根目录打开代码编辑器。
这是我的终端显示的内容!
npm ERR! code EACCES
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/yarn/bin/yarn.js
npm ERR! dest /usr/local/bin/yarn
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/yarn/bin/yarn.js' -> '/usr/local/bin/yarn'
npm ERR! { [Error: EACCES: permission denied, symlink '../lib/node_modules/yarn/bin/yarn.js' -> '/usr/local/bin/yarn']
npm ERR! cause:
npm ERR! { Error: EACCES: permission denied, symlink '../lib/node_modules/yarn/bin/yarn.js' -> '/usr/local/bin/yarn'
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'symlink',
npm ERR! path: '../lib/node_modules/yarn/bin/yarn.js',
npm ERR! dest: '/usr/local/bin/yarn' },
npm ERR! stack:
npm ERR! 'Error: EACCES: permission denied, symlink \'../lib/node_modules/yarn/bin/yarn.js\' -> \'/usr/local/bin/yarn\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'symlink',
npm ERR! path: '../lib/node_modules/yarn/bin/yarn.js',
npm ERR! dest: '/usr/local/bin/yarn' }
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! /home/ritik/.npm/_logs/2020-07-03T19_44_34_737Z-debug.log
这是一个权限问题。您可以使用它sudo
来解决此问题,但一般建议不要运行npm install
,sudo
因为这通常是个坏主意,您可以在此处了解更多信息
因此,为了最大程度地减少此问题,您可以将npm配置为使用其他目录进行全局软件包安装,如此处的npm文档中所述
在命令行的主目录中,创建用于全局安装的目录:
mkdir ~/.npm-global
配置npm以使用新的目录路径:
npm config set prefix '~/.npm-global'
在您喜欢的文本编辑器中,打开或创建一个~/.profile
文件并添加以下行:
export PATH=~/.npm-global/bin:$PATH
在命令行上,更新系统变量:
source ~/.profile
Finnaly尝试在全球范围内安装expo-cli:
npm install -g expo-cli
或者,如果您想快速修复,可以尝试一下
打开一个终端并运行:
sudo chown -R $USER:$USER /usr/local/lib/node_modules
尝试安装expo-cli,运行:
npm i -g expo-cli
还请考虑避免安装和使用globall,npx
请在此处阅读更多内容
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句