我正在尝试让 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.
相关:
- 全局 bin 的位置与文档不匹配 github/yarnpkg/yarn/issues/1194
更多推荐
纱线全局安装到当前目录
发布评论