我在安装我的react-native项目时遇到此错误-
/Users/username/.rvm/scripts/rvm: line 12: uname: command not found
/Users/username/.rvm/scripts/rvm: line 29: ps: command not found
/Users/username/Desktop/Applications/SegmentTestApp/ios/Pods/../../node_modules/react-native/React/FBReactNativeSpec/../../scripts/generate-specs.sh:
line 27: readlink: command not found
/Users/username/Desktop/Applications/SegmentTestApp/ios/Pods/../../node_modules/react-native/React/FBReactNativeSpec/../../scripts/generate-specs.sh:
line 27: dirname: command not found
/Users/username/Desktop/Applications/SegmentTestApp/ios/Pods/../../node_modules/react-native/React/FBReactNativeSpec/../../scripts/generate-specs.sh:
line 27: cd: : No such file or directory Command PhaseScriptExecution
failed with a nonzero exit code
这是我的 ~/.zshrc 文件 -
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
环境-
❯ echo $PATH
/Users/<username>/.rvm/gems/ruby-3.0.0/bin:/Users/<username>/.rvm/gems/ruby-3.0.0@global/bin:/Users/<username>/.rvm/rubies/ruby3.0.0/bin:/usr/local/opt/coreutils/libexec/gnubin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Applications/Wireshark.app/Contents/MacOS:/Applications/Postgres.app/Contents/Versions/latest/bin:/Users/<username>/Library/Android/sdk/emulator:/Users/<username>/Library/Android/sdk/tools:/Users/<username>/Library/Android/sdk/platform-tools:/Users/<username>/.rvm/bin
解决方案#1
日志中的以下错误消息表明命令行工具无法理解 RVM 脚本中的 uname 或 ps 引用。
/Users/username/.rvm/scripts/rvm: line 12: uname: command not found
我很好奇uname的下落,所以我这么做了 -
> which uname
/usr/local/opt/coreutils/libexec/gnubin/uname
此路径已添加到我的 .zshrc 文件中,如上面所示,但仍然没有解决问题。
打开RVM脚本后,我发现它没有使用zsh shell,而是使用bash shell,所以我在最后的.bash_profile文件中添加了这个uname路径 -
export PATH=/usr/local/opt/coreutils/libexec/gnubin:$PATH
它开始工作了。
解决方案#2
其他替代解决方案可以是将 rvm 脚本的 shell 从 zsh 更改为 bash。只需更改脚本的第一行
#!/usr/bin/<<shell name - bash/zsh>>
npm start>react-native start
node_modules/.bin/react-native:第 2 行:sed:找不到命令 node_modules/.bin/react-native:第 2 行:dirname:找不到命令 node_modules/.bin/react-native:第 4 行:uname:找不到命令
解决方案 => 使用“git bash”而不是“powershell”。
它对我有用