Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mac下init rn项目,windows中运行android提示rn-style-transformer sass uri must have scheme 'file:'. #14983

Open
arnehuo opened this issue Dec 14, 2023 · 3 comments
Labels
F-react Framework - React T-rn Target - 编译到 React Native V-3 Version - 3.x

Comments

@arnehuo
Copy link

arnehuo commented Dec 14, 2023

相关平台

React Native

使用框架: React

复现步骤

在mac下3.6.20版本按照文档init,使用集成模式默认reactnative模板,sass。
在mac下android,ios能正常运行。
到windows环境下,运行
yarn android
结果rn-style-transformer插件出现sass错误

期望结果

能正常编译处理sass,正常运行

实际结果

transform[stderr]: D:\work\source\photoai-app\node_modules@tarojs\rn-style-transformer\node_modules\sass\sass.dart.js:27460
transform[stderr]: throw error;
transform[stderr]: ^
transform[stderr]:
transform[stderr]: Error: Invalid argument(s): Uri d:%5Cwork%5Csource%5Cphotoai-app%5Csrc%5Cstyles%5Ccommon.scss must have scheme 'file:'.
transform[stderr]: at Object.wrapException (D:\work\source\photoai-app\node_modules@tarojs\rn-style-transformer\node_modules\sass\sass.dart.js:1240:17)
transform[stderr]: at WindowsStyle.pathFromUri$1 (D:\work\source\photoai-app\node_modules@tarojs\rn-style-transformer\node_modules\sass\sass.dart.js:33270:17)
transform[stderr]: at StaticClosure.fromUri (D:\work\source\photoai-app\node_modules@tarojs\rn-style-transformer\node_modules\sass\sass.dart.js:16166:37)
transform[stderr]: at Object.NullableExtension_andThen0 (D:\work\source\photoai-app\node_modules@tarojs\rn-style-transformer\node_modules\sass\sass.dart.js:18492:40)
transform[stderr]: at Object._wrapException (D:\work\source\photoai-app\node_modules@tarojs\rn-style-transformer\node_modules\sass\sass.dart.js:13049:14)
transform[stderr]: at _render_closure1.call$2 (D:\work\source\photoai-app\node_modules@tarojs\rn-style-transformer\node_modules\sass\sass.dart.js:82164:21)
transform[stderr]: at _RootZone.runBinary$3$3 (D:\work\source\photoai-app\node_modules@tarojs\rn-style-transformer\node_modules\sass\sass.dart.js:27587:18)
transform[stderr]: at _FutureListener.handleError$1 (D:\work\source\photoai-app\node_modules@tarojs\rn-style-transformer\node_modules\sass\sass.dart.js:26136:19)
transform[stderr]: at _Future__propagateToListeners_handleError.call$0 (D:\work\source\photoai-app\node_modules@tarojs\rn-style-transformer\node_modules\sass\sass.dart.js:26434:49)
transform[stderr]: at Object._Future__propagateToListeners (D:\work\source\photoai-app\node_modules@tarojs\rn-style-transformer\node_modules\sass\sass.dart.js:4550:77)
transform[stderr]: at _Future._completeError$2 (D:\work\source\photoai-app\node_modules@tarojs\rn-style-transformer\node_modules\sass\sass.dart.js:26266:9)

环境信息

👽 Taro v3.6.20


  Taro CLI 3.6.20 environment info:
    System:
      OS: Windows 11 10.0.22631
    Binaries:
      Node: 18.19.0 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.22.21 - ~\AppData\Roaming\npm\yarn.CMD
      npm: 10.2.3 - C:\Program Files\nodejs\npm.CMD
    npmPackages:
      @tarojs/cli: 3.6.20 => 3.6.20
      @tarojs/components: 3.6.20 => 3.6.20
      @tarojs/helper: 3.6.20 => 3.6.20
      @tarojs/plugin-framework-react: 3.6.20 => 3.6.20
      @tarojs/plugin-platform-alipay: 3.6.20 => 3.6.20
      @tarojs/plugin-platform-h5: 3.6.20 => 3.6.20
      @tarojs/plugin-platform-jd: 3.6.20 => 3.6.20
      @tarojs/plugin-platform-qq: 3.6.20 => 3.6.20
      @tarojs/plugin-platform-swan: 3.6.20 => 3.6.20
      @tarojs/plugin-platform-tt: 3.6.20 => 3.6.20
      @tarojs/plugin-platform-weapp: 3.6.20 => 3.6.20
      @tarojs/react: 3.6.20 => 3.6.20
      @tarojs/rn-runner: 3.6.20 => 3.6.20
      @tarojs/rn-supporter: 3.6.20 => 3.6.20
      @tarojs/runtime: 3.6.20 => 3.6.20
      @tarojs/runtime-rn: 3.6.20 => 3.6.20
      @tarojs/shared: 3.6.20 => 3.6.20
      @tarojs/taro: 3.6.20 => 3.6.20
      @tarojs/taro-loader: 3.6.20 => 3.6.20
      @tarojs/taro-rn: 3.6.20 => 3.6.20
      @tarojs/webpack5-runner: 3.6.20 => 3.6.20
      babel-preset-taro: 3.6.20 => 3.6.20
      eslint-config-taro: 3.6.20 => 3.6.20
      expo: ~47.0.3 => 47.0.14
      react: ^18.1.0 => 18.2.0
      react-native: ^0.70.1 => 0.70.14

补充信息

应该是rn-style-transformer插件依赖的sass uri的路径问题,使用更新的sass版本已经修复此问题。
老依赖 "sass": "1.37.5"
新依赖 "sass": "1.38.1"
测试解决问题

@ZakaryCode ZakaryCode added V-3 Version - 3.x F-react Framework - React T-rn Target - 编译到 React Native labels Dec 21, 2023
@zhiqingchen
Copy link
Member

升级有其他问题,可本地使用 resolution 解决
#11983

@fengwangyang
Copy link
Contributor

在rn-style-transformer的sass 文件importer 里加 if(isWindows){ prev = decodeURIComponent(prev)}可以解决这个 在sass报改错的问题。我调试了过后发现是sass在import回调后的prev被编码,然后执行path.isAbsolute(prev)判断时为false导致的问题。但是sass2.0版本过后取消render api, 希望后续这里能更进

@zhiqingchen
Copy link
Member

方便的话,可以提供下 pr @fengwangyang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-rn Target - 编译到 React Native V-3 Version - 3.x
Projects
None yet
Development

No branches or pull requests

4 participants