React-Native / Expo / Cygwin“意外令牌”问题

时间:2019-01-23 01:17:41

标签: powershell react-native cygwin expo

在安装react-devtools之后,我不再能够运行expo-cli。 一切正常,直到我做到了。我现在收到以下错误。 我的Powershell权限也更改为“受限”。我已将注册表恢复到前一天,并已卸载/重新安装了node和yarn以解决此问题。

错误列出了Cygwin,我没有将其安装在计算机上(未在注册表搜索中显示),但是,在搜索计算机时,我看到Cygwin随Git一起安装:

C:\ Program Files \ Git \ usr \ share \ cygwin
C:\ Program Files \ Git \ usr \ bin \ cygwin-console-helper.exe
C:\ Program Files \ Android \ Android Studio \ bin \ lldb \ lib \ distutils \ cygwinccompiler.py
C:\ Program Files \ Git \ usr \ lib \ perlS \ core_per | \ File \ Spec \ cygwin.pm
C:\ Program Files \ Git \ usr \ share \ cygwin \ cygwin.ldif
C:\ Program Files \ Git \ usr \ share \ tern1info \ 63 \ cygwin
C:\ Program Files \ Git \ usr \ lib \ terminf0 \ 63 \ cygwin

任何帮助将不胜感激。
Windows 10
npm:6.6.0
节点:v10.15.0
纱线:v1.13.0

expo start --android
At C:\Users\name\AppData\Local\Yarn\bin\expo.ps1:5 char:13
+     *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
+             ~
Unexpected token ')' in expression or statement.
At C:\Users\name\AppData\Local\Yarn\bin\expo.ps1:8 char:3
+ if [ -x "$basedir/pwsh" ]; then
+   ~
Missing '(' after 'if' in if statement.
At C:\Users\name\AppData\Local\Yarn\bin\expo.ps1:8 char:5
+ if [ -x "$basedir/pwsh" ]; then
+     ~
Missing type name after '['.
At C:\Users\name\AppData\Local\Yarn\bin\expo.ps1:9 char:20
+ ... edir/pwsh"  "$basedir/../Data/global/node_modules/.bin/expo.ps1" "$@" ...
+   
Unexpected token '"$basedir/../Data/global/node_modules/.bin/expo.ps1"' in expression or statement.
At C:\Users\name\AppData\Local\Yarn\bin\expo.ps1:9 char:73
+ ... edir/pwsh"  "$basedir/../Data/global/node_modules/.bin/expo.ps1" "$@"
+   
Unexpected token '"$@"' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : UnexpectedToken

@supermerio

C:\ Users \ name \ AppData \ Local \ Yarn \ bin \ expo.ps1

#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")

case `uname` in
    *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac

if [ -x "$basedir/pwsh" ]; then
  "$basedir/pwsh"  "$basedir/../Data/global/node_modules/.bin/expo.ps1" "$@"
  ret=$?
else 
  pwsh  "$basedir/../Data/global/node_modules/.bin/expo.ps1" "$@"
  ret=$?
fi
exit $ret

此外,我还可以通过将博览会安装到我的仓库中并从那里调用它来使博览会工作。 我注意到本地脚本与全局安装中的脚本有所不同。本地脚本称为“节点”,而全局脚本(以上)称为“ pwsh”。

\ LactFacts \ lactfact_190118 \ node_modules.bin \ expo:

#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")

case `uname` in
    *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac

if [ -x "$basedir/node" ]; then
  "$basedir/node"  "$basedir/../expo-cli/bin/expo.js" "$@"
  ret=$?
else 
  node  "$basedir/../expo-cli/bin/expo.js" "$@"
  ret=$?
fi
exit $ret

2 个答案:

答案 0 :(得分:1)

这是一个已知的纱线1.13.0问题:https://github.com/yarnpkg/yarn/issues/6902#issuecomment-453534280

答案 1 :(得分:0)

似乎“ C:\ Users \ name \ AppData \ Local \ Yarn \ bin \ expo.ps1”中的内容均具有格式错误的if语句。

您可以查看该文件以进行确认吗?如果可能,请在此处发布。