纱线全局安装到当前目录

时间:2016-10-30 15:44:30

标签: react-native yarnpkg

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

$ 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项目时,我得到:

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

快来找出,yarn正在将依赖项安装到当前目录中,而不是全局安装它。对此有何帮助?我正在运行Lubuntu 16.04。

1 个答案:

答案 0 :(得分:1)

修改

现在works

yarn config set prefix /usr/local

检查

yarn config get prefix

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

在Windows上我做:

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

全球路径isn't configurable permanently。我们只能阅读设置:

> yarn global bin
C:\Program Files\nodejs

当我尝试安装elm-upgrade时,我在日志%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

相关: