纱线全局安装到当前目录 [英] Yarn global installs to current directory

查看:67
本文介绍了纱线全局安装到当前目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让 React Native 在我的 Linux 机器上运行.为了让 cli 运行,我运行了:

I am trying to get React Native working on my Linux machine. In order to get the cli running I have run:

$ yarn global add react-native-cli

并查看:

yarn global v0.16.1
warning No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed react-native-cli@1.0.0 with binaries:
      - react-native
Done in 1.70s.

一切都安装得很好,但是当我尝试创建一个新的 React Native 项目时,我得到:

Everything installs just fine, but when I attempt to create a new React Native project, I get:

$ react-native init Test
react-native: command not found

来发现,yarn 正在将依赖项安装到当前目录中的任何位置,而不是全局安装它.这有什么帮助吗?我正在运行 Lubuntu 16.04.

Come to find out, yarn is installing the dependency into whatever the current directory is instead of installing it globally. Any help on this? I'm running Lubuntu 16.04.

推荐答案

编辑

现在它工作:

yarn config set prefix/usr/local

检查

yarn config 获取前缀

请注意,只有可执行文件才会安装到此 prefix 位置.Windows 上的软件包安装在 %USERPROFILE%\AppData\Local\Yarn\config\global\node_modules 中.

Notice that only executables will be installed to this prefix location. Packages i.e. on Windows are installed in %USERPROFILE%\AppData\Local\Yarn\config\global\node_modules.

在 Windows 上我这样做:

On Windows I do:

mkdir ~/yarn-global
yarn config set prefix ~/yarn-global

全局路径尚未永久配置.我们只能读取设置:

> yarn global bin
C:\Program Files\nodejs

当我尝试安装 elm-upgrade 时,日志中出现错误 %USERPROFILE%\AppData\Local\Yarn\config\global\yarn-error.log

When I tried to install elm-upgrade, I got error in log %USERPROFILE%\AppData\Local\Yarn\config\global\yarn-error.log

Trace:
  Error: EPERM: operation not permitted, open 'C:\Program Files\nodejs\elm-upgrade.cmd'
      at Error (native)

但是elm-upgrade安装在%USERPROFILE%\AppData\Local\Yarn\config\global\node_modules\.bin.

But elm-upgrade was installed in %USERPROFILE%\AppData\Local\Yarn\config\global\node_modules\.bin.

相关:

这篇关于纱线全局安装到当前目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆